Skip to content

Syntax error in test file makes pytest exit with exit code 2 #4603

Description

@martinsmid

Ubuntu 18.04
pytest-4.0.2
python 2.7 and 3.6

Description

Having a test file with syntax error or import error results in pytest exiting with exitcode 2.

How to reproduce

  1. Create a file named test_syntax_error.py with content
def x:
    pass
  1. Run pytest and print exit code
    pytest test_syntax_error.py; echo $?

Expected

Probably worth a new exitcode as it doesn't really fit into those 5 documented

Actual

Exits with code 2, which stands for "Test execution was interrupted by the user"

Similarly, a file with content import non_existent will have the same effect.

This issue is similar to #2832 and also
#2950, but still I hope this will be useful for reference and example.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions