[TIP] Incorrect return code py.test on Windows/Jenkins ?

Jorge Vargas jorge.vargas at gmail.com
Mon Mar 21 11:27:05 PDT 2011

On Mon, Mar 21, 2011 at 1:44 PM, Pere Martir <pere.martir4 at gmail.com> wrote:
> The return code of py.test on Windows makes Jenkins to consider the
> build "failed" if there is any failed testcase in the generated JUnit
> XML.

Why you want the build to pass if the tests failed ?

> I have to put a superfluous command after py.test to make Jenkins
> not to consider it as a failed build.

I'm not sure how it works on windows, but on Linux you can put a
shebang on top of the shell section in order to make it ask for the
return of the last command only. Pasted-from-jenkins-help

Execute shell

Runs a shell script (defaults to sh, but this is configurable) for
building the project. The script will be run with the workspace as the
current directory. Type in the contents of your shell script. If your
shell script has no header line like #!/bin/sh —, then the shell
configured system-wide will be used, but you can also use the header
line to write script in another language (like #!/bin/perl) or control
the options that shell uses.
By default, the shell will be invoked with the "-ex" option. So all of
the commands are printed before being executed, and the build is
considered a failure if any of the commands exits with a non-zero exit
code. Again, add the #!/bin/... line to change this behavior.

As a best practice, try not to put a long shell script in here.
Instead, consider adding the shell script in SCM and simply call that
shell script from Jenkins (via bash -ex myscript.sh or something like
that), so that you can track changes in your shell script.

> Jenkins: 1.401.
> platform win32 -- Python 2.6.4 -- pytest-2.0.3.dev
> (I can reproduce it on 2.0.1 and 2.0.2 as well)
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list