-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
TST: Various fixes prior to switching to pytest #10790
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
The `assert_raises` and `assert_raises_regex` testing utilities were being imported from nose, which in turn took them from unittest `assertRaises` and `assertRaisesRegex`. We takeover the nose procedure here so that these commonly used utilities no longer have a nose dependence. The `raises` decorator continues to have a nose dependency, but that only shows up when used, and NumPy does not use it. Document that and otherwise leave it be.
Renaming the C test modules is likely the most risky bit here. It is possible that someone, somewhere, is using the |
numpy/core/tests/french_locale.py
Outdated
__ALL__ = ['FrenchLocale'] | ||
|
||
|
||
def find_french_locale(): |
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.
Naming: I think the point is not to switch to specifically French locale, but to a locale where the decimal separator is comma and not period.
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.
Agree in general, but I chose "French" so folks would know what the locale used was. Maybe "DecimalPointAsComma" or some such?
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.
Or let's just keep it as "french" and not bikeshed, the docstring already seems to say what it's for.
Otherwise, this PR is LGTM.
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.
OK, lets leave it. If changes are needed at some point, fixing things up should be easy enough, just a few additions and name changes.
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, I changed things as there is also the possibility of a Finnish locale :-) Renamed the module _locales.py
and the class to CommaDecimalPointLocale
.
9f89d49
to
d1e768b
Compare
Add class CommaDecimalPointLocale that can be used for testing in a LC_NUMERIC locale where the decimal point is a comma. It functions either as a context manager or as a base class with setup and teardown methods. Both uses raise SkipTest when no suitable locale is available.
The renamed C modules provide low level functions for testing. The rename marks them as private functions and makes them invisible to pytest by default.
Avoids pytest collection time warnings.
These tests were not included in the `setup.py` file and consequently not available in the installed numpy for testing.
We are testing scikit-learn on numpy dev wheels and we found that this PR broke our tests, see (scikit-learn/scikit-learn#10880 for more details). For some reason (very likely purely historical), We fixed this in scikit-learn master but this will affect the latest scikit-learn release (0.19.1) as soon as numpy 1.15 is released. Given the current rate of release, it is rather likely that numpy 1.15 will be released before the next scikit-learn release (0.20). Would you be willing to consider reverting the renaming of the compiled C test modules or reinstating the old modules with some deprecation period, which ever you like best? I am not sure what the problem with pytest was but I am reasonably confident that there is a way for pytest to ignore/skip these modules. I worked on the pytest move in scikit-learn and I can definitely think about how to do this if that's helpful. |
@lesteve Could you open an official issue? The |
Done in #10845. |
With these changes we have the following results when testing with pytest/nose on Python 2.7.
Changes
TST: Add numpy/compat/tests
These tests were not included in the
setup.py
file and consequentlynot available in the installed numpy for testing.
TST: Do not import functions beginning
test_
.Avoids pytest collection time warnings.
TST: Rename some compiled c test modules
The renamed C modules provide low level functions for testing. The
rename marks them as private functions and makes them invisible to
pytest by default.
TST: Remove nose dependence of locale tests.
Add class CommaDecimalPointLocale that can be used for testing in a
LC_NUMERIC locale where the decimal point is a comma. It functions
either as a context manager or as a base class with setup and teardown
methods. Both uses raise SkipTest when no suitable locale is available.
TST: Remove some nose dependences in utils.py
The
assert_raises
andassert_raises_regex
testing utilities werebeing imported from nose, which in turn took them from unittest
assertRaises
andassertRaisesRegex
. We takeover the nose procedurehere so that these commonly used utilities no longer have a nose
dependence.
The
raises
decorator continues to have a nose dependency, but thatonly shows up when used, and NumPy does not use it. Document that and
otherwise leave it be.