-
Notifications
You must be signed in to change notification settings - Fork 7
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 for running setup.py nosetests
#7
Changes from 2 commits
8b4e6aa
213e7a9
bdfe964
ead4cd8
f10bd82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
|
||
import nose.plugins | ||
|
||
__version__ = "0.5" | ||
__version__ = "0.5-post3" | ||
|
||
SUBPROCESS_ENV_KEY = "NOSE_WITH_PROCESS_ISOLATION_REPORTER" | ||
|
||
|
@@ -147,12 +147,16 @@ def __call__(self, result): | |
useshell = True | ||
|
||
self.logger.debug("Executing %s", " ".join(argv)) | ||
popen = subprocess.Popen(argv, | ||
cwd=self._cwd, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
shell=useshell, | ||
) | ||
try: | ||
popen = subprocess.Popen(argv, | ||
cwd=self._cwd, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
shell=useshell, | ||
) | ||
except OSError, e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just tried this with Python 3 and noticed this is Python 2 only code - it should instead be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed this as well as the # in comment. How are you testing? I’ve tried setup.py nosetests and get lots of problems.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran into this just running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should note, after installing this I just ran through my normal tests with nosetests to make sure nothing was broken with this change. I don't normally run via setup.py. Does this now fix your issue without problems? I'm confused by your last comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm running with https://travis-ci.org/mdprewitt/nosepipe/jobs/51232640 I'm also messing around with seeing how I can fix this here: |
||
raise Exception("Error running %s [%s]" % (argv[0], e)) | ||
|
||
try: | ||
stdout = popen.stdout | ||
while True: | ||
|
@@ -191,15 +195,31 @@ def __init__(self): | |
nose.plugins.Plugin.__init__(self) | ||
self._test = None | ||
self._test_proxy = None | ||
self._argv = [os.path.abspath(sys.argv[0]), | ||
'--with-process-isolation-reporter'] | ||
self._argv += ProcessIsolationPlugin._get_nose_whitelisted_argv() | ||
nosearg = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment over this section describing why we're doing this would be good. |
||
for i in range(0, len(sys.argv)): | ||
if 'nosetests' in sys.argv[i]: | ||
self._argv = [sys.argv[i]] | ||
nosearg = i | ||
break | ||
|
||
if nosearg is None: | ||
raise Exception("nosetests not found in command-line") | ||
|
||
# self._argv = [os.path.abspath(sys.argv[0])] | ||
# if 'nosetests' not in sys.argv[0]: | ||
# for i in range(1, len(sys.argv)): | ||
# self._argv += [sys.argv[i]] | ||
# if 'nosetests' in sys.argv[i]: | ||
# break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just remove the commented code rather than leaving it here commented. |
||
|
||
self._argv += ['--with-process-isolation-reporter'] | ||
self._argv += ProcessIsolationPlugin._get_nose_whitelisted_argv(nosearg=nosearg) | ||
# Getting cwd inside SubprocessTestProxy.__call__ is too late - it is | ||
# already changed by nose | ||
self._cwd = os.getcwd() | ||
|
||
@staticmethod | ||
def _get_nose_whitelisted_argv(): | ||
def _get_nose_whitelisted_argv(nosearg=0): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you rename this new argument to something with more meaning in this function - perhaps "offset"? I'd also like to see the +1 added to the argument before passing it in, rather than doing it multiple times inside of here. |
||
# This is the list of nose options which should be passed through to | ||
# the launched process; boolean value defines whether the option | ||
# takes a value or not. | ||
|
@@ -228,7 +248,7 @@ def _get_nose_whitelisted_argv(): | |
'--doctest-options': True, | ||
'--no-skip': False, | ||
} | ||
filtered = set(whitelist.keys()).intersection(set(sys.argv[1:])) | ||
filtered = set(whitelist.keys()).intersection(set(sys.argv[nosearg + 1:])) | ||
result = [] | ||
for key in filtered: | ||
result.append(key) | ||
|
@@ -237,7 +257,7 @@ def _get_nose_whitelisted_argv(): | |
|
||
# We are not finished yet: options with '=' were not handled | ||
whitelist_keyval = [(k + "=") for k, v in whitelist.items() if v] | ||
for arg in sys.argv[1:]: | ||
for arg in sys.argv[nosearg + 1:]: | ||
for keyval in whitelist_keyval: | ||
if arg.startswith(keyval): | ||
result.append(arg) | ||
|
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.
You can leave out any version changes, as those will be done when a new release is made - right now this might conflict as 0.6 has been released.