-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
PR: Delay check whether we are running under pytest until run time #6540
Conversation
Hello @jitseniesen! Thanks for updating the PR.
Comment last updated on February 28, 2018 at 09:58 Hours UTC |
The important change is the one at the top of I checked the time taken to evaluate The PEP8 complaint is not my fault. |
spyder/app/start.py
Outdated
@@ -21,7 +21,8 @@ | |||
|
|||
# Local imports | |||
from spyder.app.cli_options import get_options | |||
from spyder.config.base import PYTEST, get_conf_path, running_in_mac_app | |||
from spyder.config.base import ( | |||
get_conf_path, running_in_mac_app, running_under_pytest) |
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.
Please change this to
from spyder.config.base import (get_conf_path, running_in_mac_app,
running_under_pytest)
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.
This is just the way we write multi-line imports in most of our codebase :-)
Really cool! I didn't think this was possible, given the complexity of Spyder's test suite. Thanks a lot for working on this! I only have one question: any reason to not make this against 3.x? Given that we still have to support that branch, I'd prefer not to deal with two different ways of checking for Pytest in our codebase. |
PYTEST = os.environ.get('SPYDER_PYTEST') | ||
def running_under_pytest(): | ||
""" | ||
Return True if currently running under py.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.
This is trivially minor, but though while PEP 257 allows it, it seems to be convention that we put the summary one-liner on the first line, next to the '''
.
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.
Really? I always thought it was the other way around ... I had a quick and random look in our code base. To me, it looks like we have far too few multi-line docstrings and that there is no clear preference for either style. We may need an executive decision here.
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.
Hmmm actually I like either
def func():
"""Summary."""
or
def func():
"""
Summary.
Something extra.
"""
I don't like this at all :-p
def func():
"""Summary.
Something extra.
"""
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.
+1 for
def func():
"""
Summary.
Some
"""
I like to write docstrings this way too.
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.
I prefer it as well. My concern was only with regard to consistency with the rest of Spyder's codebase, which seemed to mostly use the """Summary line'''
form, but I'd be happy to switch.
Only that it did not seem necessary to me and that I hadn't tested it. But I just tested it now and it works, so I will change the base. |
9ee03c6
to
b25f218
Compare
Great, thanks! |
Currently, the test whether the environment variable
SPYDER_PYTEST
is set (which indicates whether we are running under pytest) is done at import time. However, if the tests are run using the unittest plugin, this import happens before the environment variable is actually set. Thus, this PR delays the test until run time.With this PR and spyder-ide/spyder-unittest#114, I can run the Spyder test suite successfully within Spyder. 🎉