Skip to content

Pytest exit codes for command line errors look incorrect #3913

@rdadolf

Description

@rdadolf

According to the documentation, the CLI return value for a bug on the command line should be 4. From what I can tell, all bugs return 2.

$ pytest -invalid-
pytest: error: unrecognized arguments: -invalid-
  inifile: None
  rootdir: /tmp
$ echo $?
2
$ pytest -v-v
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument -v/--verbose: ignored explicit argument '-v'
$ echo $?
2

It looks like interrupting PyTest does return 2, however:

$ pytest xgt_test.py 
================================ test session starts ================================
platform linux2 -- Python 2.7.15rc1, pytest-3.7.2, py-1.5.4, pluggy-0.7.1
rootdir: /gems/build/apps/mygems, inifile:
collected 26 items                                                                  

xgt_test.py EEEEEEEEEEE^C
<snip>
$ echo $?
2

System configuration:

$ pytest --version
This is pytest version 3.7.2, imported from /usr/local/lib/python2.7/dist-packages/pytest.pyc
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"

Happy to answer questions, and apologies if I've misunderstood the intended behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions