Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 5 commits into from
Mar 24, 2018

Conversation

charris
Copy link
Member

@charris charris commented Mar 23, 2018

With these changes we have the following results when testing with pytest/nose on Python 2.7.

numpy/linalg/tests
    pytest -- run:121 skipped:0 slow:22
    nose   -- run:121 skipped:0 slow:22
numpy/testing/tests
    pytest -- run:118 skipped:4
    nose   -- run:122 skipped:0
numpy/random/tests
    pytest -- run:138 skipped:0 slow:0
    nose   -- run:138 skipped:0 slow:0
numpy/ma/tests
    pytest -- run:445 skipped:2 slow:0
    nose   -- run:445 skipped:2 slow:0
numpy/distutils/tests
    pytest -- run:27 skipped:0 slow:0
    nose   -- run:27 skipped:0 slow:0
numpy/fft/tests
    pytest -- run:30 skipped:0 slow:0
    nose   -- run:30 skipped:0 slow:0
numpy/polynomial/tests
    pytest -- run:451 skipped:0 slow:0
    nose   -- run:451 skipped:0 slow:0
numpy/compat/tests
    pytest -- run:1 skipped:0
    nose   -- run:1 skipped:0
numpy/tests
    pytest -- run:19 skipped:0
    nose   -- run:19 skipped:0
numpy/core/tests
    pytest -- run:2004 skipped:11 slow:10
    nose   -- run:2004 skipped:11 slow:10
numpy/lib/tests
    pytest -- run:1156 skipped:3 slow:5
    nose   -- run:1156 skipped:3 slow:5
numpy/f2py/tests
    pytest -- run:365 skipped:0 slow:31
    nose   -- run:365 skipped:0 slow:31
numpy/matrixlib/tests
    pytest -- run:50 skipped:0 slow:0
    nose   -- run:50 skipped:0 slow:0

Changes

TST: Add numpy/compat/tests

These tests were not included in the setup.py file and consequently
not 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 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.

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.
@charris
Copy link
Member Author

charris commented Mar 24, 2018

Renaming the C test modules is likely the most risky bit here. It is possible that someone, somewhere, is using the rational user type.

__ALL__ = ['FrenchLocale']


def find_french_locale():
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

@charris charris force-pushed the pytest-prep branch 2 times, most recently from 9f89d49 to d1e768b Compare March 24, 2018 15:38
charris added 4 commits March 24, 2018 09:52
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.
@lesteve
Copy link
Contributor

lesteve commented Apr 3, 2018

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), numpy.core.umath_tests.inner1d was used in some of the scikit-learn code.

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.

@charris
Copy link
Member Author

charris commented Apr 3, 2018

@lesteve Could you open an official issue?

The numpy.core.umath_tests name is not actually a problem, pytest ignores plural tests by default, however, I don't want downstream projects using numpy internal testing routines. What sort of warning do you suggest?

@lesteve
Copy link
Contributor

lesteve commented Apr 4, 2018

Done in #10845.

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.

4 participants