-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fixes #1210 adds stderr write for pytest.exit(msg) call #1655
Conversation
Thanks! Could you please take a look at the failing test? I also think this should go to the |
excinfo = _pytest._code.ExceptionInfo() | ||
config.hook.pytest_keyboard_interrupt(excinfo=excinfo) | ||
session.exitstatus = EXIT_INTERRUPTED | ||
except pytest.Exit as e: | ||
sys.stderr.write('{0}: {1}\n'.format(type(e).__name__, e.msg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the session.exitstatus when pytest.Exit is caught? It looks like it might be 0 and before this change it was EXIT_INTERNALERROR. But I might be wrong... maybe check it in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I will have the test verify this.
Thanks @JonathonSonesen! 😁 Closing this for now, as it should target |
Yeah no problem i will get this fixed up! |
@@ -90,10 +90,12 @@ def wrap_session(config, doit): | |||
session.exitstatus = doit(config, session) or 0 | |||
except pytest.UsageError: | |||
raise | |||
except KeyboardInterrupt: | |||
except KeyboardInterrupt as e: | |||
excinfo = _pytest._code.ExceptionInfo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few points:
- there's no need for
as e
because the exception data is already inexcinfo
- I'm unsure if this is the right place to do the outputting
- I tested
pytest.exit
ing from a test, and it now prints the msg twice - I think investigating this and why it doesn't print whenpytest.exit
ing frompytest_configure
will point to the right place to do the outputting - also when the tests ran, I saw quite a few errors - these will also help point to a good solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes thanks for bringing this up again, I think it may have to do with the init_state logic that we were talking about prior to your departure.
I will do more work on this for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonathonSonesen cool! Ping me a message if you wanna discuss it.
This PR addresses issue #1210 writing the exception message to stderr as well as the class name of the exception.