-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Ability to skip tests or allow errors due to SyntaxError #2817
Comments
That's what I would suggest as an workaround. |
I don't think there's a way for pytest to even import a module with the |
i also already told on irc that the only way to handle this is to use a extra module and ignore_collect within a module it is impossible to do at a sane cost |
I agree, the |
|
@anlutro thanks for following up. I'm closing this, but if you would like to contribute an example to the docs it would be very welcome. 👍 |
I have a test that works with Python 3 type hints. I can easily deal with the
typing
module not existing in Python < 3.5 by usingpytest.importorskip
, however, in my test file I'm using type annotations like these:This is not valid Syntax in Python 2.7, so the test run errors.
As a temporary workaround, I will be moving my stubs with invalid Python 2 syntax to a separate module and deal with the SyntaxError myself, but it would be nice if I could just configure pytest to either skip importing the test at all or skip the error.
The SyntaxError already gets caught here, so it shouldn't be impossible to add some custom behaviour into the except clause.
The text was updated successfully, but these errors were encountered: