Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support pytest 5.0.0+ exit codes #198

Closed

Conversation

mikaelarguedas
Copy link
Contributor

@mikaelarguedas mikaelarguedas commented Jul 13, 2019

Pytest moved their exit code to an Enum class named ExitCode in 5.0.0 and up: pytest-dev/pytest@2b92fee#diff-7191acb1a6aaab2f77b6e53ce837e348

Without this change, colcon fails to run pytests with the following error:

[4.875s] ERROR:colcon.colcon_core.task.python.test:Exception in Python testing step extension 'pytest': cannot import name 'EXIT_TESTSFAILED'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/colcon_core/task/python/test/__init__.py", line 75, in test
    return await extension.step(self.context, env, setup_py_data)
  File "/usr/local/lib/python3.6/dist-packages/colcon_core/task/python/test/pytest.py", line 157, in step
    from _pytest.main import EXIT_TESTSFAILED
ImportError: cannot import name 'EXIT_TESTSFAILED'

Edit: AFAICT test failures appear unrelated to this change and are present on master cron jobs

Fixes #196.

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
@dirk-thomas
Copy link
Member

dirk-thomas commented Jul 15, 2019

Thank you for the patch.

Can you please invert the try / except logic so that the try block contains the code used moving forward and the except block contains the fallback code for earlier pytest versions.

I edited the original description to reference the issue this PR closes.

@dirk-thomas dirk-thomas added bug Something isn't working duplicate This issue or pull request already exists labels Jul 15, 2019
@dirk-thomas
Copy link
Member

AFAICT test failures appear unrelated to this change and are present on master cron jobs

Actually the failing cron jobs for master are all due to the pytest 5.0 release. Since this needs additional fixes I have created #200 which includes the changes from this PR. Therefore I will close this as a duplicate.

Anyway thank you for creating the patch.

@mikaelarguedas mikaelarguedas deleted the pytest_exit_codes branch July 16, 2019 23:42
@mikaelarguedas
Copy link
Contributor Author

Sounds good, glad it helped getting the compatibility fix in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Development

Successfully merging this pull request may close these issues.

Python tests not working with pytest 5.0.0
2 participants