Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 1 commit into from
Nov 16, 2015

Conversation

ev-br
Copy link
Contributor

@ev-br ev-br commented Nov 15, 2015

  • Bring SkipTest exception into the numpy.testing namespace, so that there is no need to import it from nose or unittest.case.
  • rename private KnownFailureTest exception into KnownFailure and expose it in the namespace

The effect is that one can do from numpy.testing import SkipTest, KnownFailure and then e.g. raise KnownFailure instead of something like knownfailureif(True, "ouch")(lambda: None)().

closes #3718

@ev-br ev-br changed the title Knownf expose KnownFailure and SkipTest exceptions in numpy.testign Nov 15, 2015
@ev-br ev-br changed the title expose KnownFailure and SkipTest exceptions in numpy.testign expose KnownFailure and SkipTest exceptions in numpy.testing Nov 15, 2015
@charris
Copy link
Member

charris commented Nov 15, 2015

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?

@ev-br
Copy link
Contributor Author

ev-br commented Nov 15, 2015

Ouch.
On Python 2.7+ nose.SkipTest is unittest.case.SkipTest, on py2.6 nose does something else. I just defined an exception with the same name on 2.6, but apparently it's a wrong kind of duck still.

The easiest thing would be to just import it from nose always, but nose is a conditional dependency.
Do we really worry about systems where nose is not available?
Or do we really worry about py 2.6?

@charris
Copy link
Member

charris commented Nov 15, 2015

do we really worry about py 2.6?

Yes.

Do we really worry about systems where nose is not available?

Not for testing.

@ev-br
Copy link
Contributor Author

ev-br commented Nov 15, 2015

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():
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8, Indentation.

@charris
Copy link
Member

charris commented Nov 16, 2015

Looks OK except for a couple of nits. I suppose at some point KnownFailureTest could be subclassed from KnownFailureTest and deprecated, although I'm not convinced that would work. Might squash some of the commits together also, but not a priority.

@charris
Copy link
Member

charris commented Nov 16, 2015

Although I do worry if anyone is using the old KnownFail plugin, I can't think of any easy way to make backward compatibility work.

Strictly speaking we should preserve the old names, while deprecating KnownFailure the plugin and adding KnownFailurePlugin as its replacement. Hmm...

* ``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.

Copy link
Member

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
@ev-br
Copy link
Contributor Author

ev-br commented Nov 16, 2015

OK, bit the bullet and made it a KnownFailureException (aliased to KnownFailureTest) and KnownFailurePlugin (aliased to KnownFailure), so that it's fully backwards compatible. Scipy test suite passes locally.

raise nose.SkipTest("Skipping locale test, because "
"French locale not found")
raise SkipTest("Skipping locale test, because "
"French locale not found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So close 8-)

charris added a commit that referenced this pull request Nov 16, 2015
expose KnownFailure and SkipTest exceptions in numpy.testing
@charris charris merged commit cbc14f0 into numpy:master Nov 16, 2015
@charris
Copy link
Member

charris commented Nov 16, 2015

Thanks Evgeni. Can't do much better with the constraints of backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KnownFailureTest should be in numpy.testing namespace
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.