Skip to content

Commit ac14548

Browse files
committed
add in the ability to filter out numpy files from consideration
while searching for tests to run
1 parent c4a824e commit ac14548

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

lib/matplotlib/ignorenumpytests.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
"""
3+
So pytest is trying to load tests in numpy, and generates this error
4+
5+
____________________________ ERROR at setup of test ____________________________
6+
file /home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/
7+
numpy/testing/nosetester.py, line 249
8+
def test(self, label='fast', verbose=1, extra_argv=None, doctests=False,
9+
fixture 'self' not found
10+
available fixtures: tmpdir_factory, pytestconfig, cov, cache, recwarn,
11+
monkeypatch, record_xml_property, capfd, capsys, tmpdir
12+
13+
use 'py.test --fixtures [testpath]' for help on them.
14+
/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/
15+
numpy/testing/nosetester.py:249
16+
17+
this file is intended to stop that behaviour, by blocking files from
18+
being considered for collection if "numpy" is in the path
19+
"""
20+
21+
def pytest_ignore_collect(path, config):
22+
if 'numpy' not in path.basename:
23+
print('allowing ', path)
24+
return True
25+
else:
26+
print('blocking ', path)
27+
return False
28+
29+
# return 'numpy' not in path.basename:

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ def run(self):
292292
package_data=package_data,
293293
classifiers=classifiers,
294294
download_url="http://matplotlib.org/users/installing.html",
295-
295+
entry_points = {
296+
'pytest11': [
297+
'ignorenumpytests = matplotlib.ignorenumpytests',
298+
]
299+
},
296300
# List third-party Python packages that we require
297301
install_requires=install_requires,
298302
setup_requires=setup_requires,

tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def run(extra_args):
3333
# to pytest.main
3434
return pytest.main(argv)
3535
else:
36+
pytest.main(['--traceconfig'])
3637
return pytest.main(argv + ['--pyargs'] + default_test_modules +
3738
['--ignore=site-packages/numpy/testing/.'])
3839

0 commit comments

Comments
 (0)