-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
expose KnownFailure and SkipTest exceptions in numpy.testing #6688
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
Conversation
Not sure what the problem with Python 2.6 is, the nose version is the same as for 2.7. Hmm... Could you add a note to 1.11.0-notes? |
Ouch. The easiest thing would be to just import it from nose always, but nose is a conditional dependency. |
Yes.
Not for testing. |
OK, CI is green |
from unittest.case import SkipTest | ||
except ImportError: | ||
# on py2.6 unittest.case is not available. Ask nose for a replacement. | ||
def _get_skip(): |
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.
Any particular reason to do this with a function?
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.
As an attempt to avoid a hard dependency on nose, parroted from other functions in this module (eg https://github.com/numpy/numpy/blob/master/numpy/testing/utils.py#L1120).
AFAICS, import_nose
either returns the nose
module or raises ImportError
.
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.
But what does _get_skip
do that helps? The only thing I can think of is that nose
goes away on return, but is seems to me that SkipTest = import_nose().SkipTest
would work as well.
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.
My first reaction was that it's a bit more mysterious, but well, it all is in the eye of the maintainer :-). Fixed.
@@ -225,7 +225,7 @@ def wrapper(*args, **kwargs): | ||
except locale.Error: | ||
pass | ||
else: | ||
raise nose.SkipTest("Skipping locale test, because " | ||
raise SkipTest("Skipping locale test, because " | ||
"French locale not found") |
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.
PEP8, Indentation.
Looks OK except for a couple of nits. I suppose at some point |
Although I do worry if anyone is using the old Strictly speaking we should preserve the old names, while deprecating |
* ``SkipTest`` and ``KnownFailure`` exception classes are exposed in the | ||
``numpy.testing`` namespace. Raise them in a test function to mark the test to | ||
be skipped or mark it as a known failure, respectively. | ||
|
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.
Should also mention that KnownFailure
plugin is gone (compatibility note), and that KnownFailureTest
should be replaced by KnownFailure
.
* use SkipTest in numpy tests instead of importing it from nose * add a KnownFailureException as an alias for KnownFailureTest (the former is preferred, but the latter is kept for backcompat) * rename the KnownFailure nose plugin into KnownFailurePlugin, and keep the old name for backcompat
OK, bit the bullet and made it a |
raise nose.SkipTest("Skipping locale test, because " | ||
"French locale not found") | ||
raise SkipTest("Skipping locale test, because " | ||
"French locale not found") |
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.
So close 8-)
expose KnownFailure and SkipTest exceptions in numpy.testing
Thanks Evgeni. Can't do much better with the constraints of backward compatibility. |
SkipTest
exception into thenumpy.testing
namespace, so that there is no need to import it fromnose
orunittest.case
.KnownFailureTest
exception intoKnownFailure
and expose it in the namespaceThe effect is that one can do
from numpy.testing import SkipTest, KnownFailure
and then e.g.raise KnownFailure
instead of something likeknownfailureif(True, "ouch")(lambda: None)()
.closes #3718