-
Notifications
You must be signed in to change notification settings - Fork 51
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
Generaloption: handle option-as-value #185
Conversation
Refer to this link for build results (access rights to CI server needed): |
@boegel this seems to works, but no unittests were added yet (and the current ones fail due to double logger somewhere, matser is fine) |
Refer to this link for build results (access rights to CI server needed): |
def parse_args(self, args=None, values=None): | ||
"""Keep a copy of the original arguments for callback / option processing""" | ||
# seems like self._get_args returns a copy, but better safe then sorry here | ||
self.orig_rargs = self._get_args(args)[:] |
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 think if you make this super(..., self)._get_args(args)
, then you can also remove the premature return
I added in self._get_args
get_env_options
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.
well, close, super
doesn't work because OptionParser
doesn't derive from object
all tests pass with stdweird#9
c558621
to
f4d8de1
Compare
Refer to this link for build results (access rights to CI server needed): |
f4d8de1
to
37c9818
Compare
Refer to this link for build results (access rights to CI server needed): |
37c9818
to
627000f
Compare
@boegel should be fine now |
All tests PASSed. See https://jenkins1.ugent.be/job/vsc-base-pr-builder/343/console for more details. |
Since #193 is merged in here, that should be reviewed/merged first, and this one should then be re-evaluated. |
@stdweird: please sync with |
627000f
to
fe624d0
Compare
All tests PASSed. See https://jenkins1.ugent.be/job/vsc-base-pr-builder/351/console for more details. |
…et_args), fixes broken test
…so redefining parse_args, which caused double paring of environment args)
fe624d0
to
a53ef03
Compare
All tests PASSed. See https://jenkins1.ugent.be/job/vsc-base-pr-builder/354/console for more details. |
All tests PASSed. See https://jenkins1.ugent.be/job/vsc-base-pr-builder/355/console for more details. |
self.mock_stderr(True) # reset | ||
self.assertErrorRegex(SystemExit, '.*', TestOption1, go_args=args) | ||
stderr = self.get_stderr() | ||
self.assertTrue(msg in stderr) |
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.
add self.mock_stderr(False)
here to disable the mocking (so we can actually see something if something is broken hard :)
maybe the self.assertErrorRegex
during mocking isn't a good idea either, will we see the actual failed test since stderr
is being mocked?
maybe this is a good place for try
/except
/finally
instead of self.assertErrorRegex
:
def _match_testoption1_sysexit(self, args, msg):
"""Check whether parsing supplied arguments with TestOption1 results in SystemExit error being raised."""
system_exit = False
self.mock_stderr(True) # reset
# purposely not using self.assertErrorRegex, since we're mocking stderr...
try:
TestOption(go_args=args)
except SytemExit:
system_exit = True
finally:
self.mock_stderr(False)
self.assertTrue(system_exit)
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.
ah, yes, and add the self.assertTrue(msg in stderr)
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 don't understand. isn't the setUp / tearDown supposed to do this? also don't understand the reamkr wrt exceptions and stderr.
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.
While you're mocking stderr, you won't get any output on stderr anymore.
The tearDown will disable the mocking, sure, but it's cleaner to do that in here (since you may be calling this method several times in a single test).
All tests PASSed. See https://jenkins1.ugent.be/job/vsc-base-pr-builder/361/console for more details. |
Generaloption: handle option-as-value
Fixes #184
Requires #193