Skip to content

Commit

Permalink
MAINT: Move conftest (mne-tools#6309)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored May 14, 2019
1 parent 9db91c1 commit 5bc0a8f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 39 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include LICENSE.txt
include requirements.txt
include mne/__init__.py

include conftest.py
recursive-include examples *.py
recursive-include examples *.txt
recursive-include tutorials *.py
Expand Down
55 changes: 55 additions & 0 deletions conftest.py → mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,58 @@
fname_fwd = op.join(s_path, 'sample_audvis_trunc-meg-eeg-oct-4-fwd.fif')


def pytest_configure(config):
"""Configure pytest options."""
# Set the timeout pretty low to ensure we do not by default add really long
# tests, or make changes that make things a lot slower
config.addinivalue_line(
'addopts',
'--showlocals --durations=20 --doctest-modules -ra --cov-report= '
'--doctest-ignore-import-errors --junit-xml=junit-results.xml '
'--ignore=doc --ignore=logo --ignore=examples --ignore=tutorials '
'--ignore=mne/gui/_*.py --timeout 30')

# Markers
for marker in ('slowtest', 'ultraslowtest'):
config.addinivalue_line('markers', marker)

# Fixtures
for fixture in ('matplotlib_config',):
config.addinivalue_line('usefixtures', fixture)

# Warnings
# - Once SciPy updates not to have non-integer and non-tuple errors (1.2.0)
# we should remove them from here.
# - This list should also be considered alongside reset_warnings in
# doc/conf.py.
warning_lines = """
error::
ignore::ImportWarning
ignore:the matrix subclass:PendingDeprecationWarning
ignore:numpy.dtype size changed:RuntimeWarning
ignore:.*HasTraits.trait_.*:DeprecationWarning
ignore:.*takes no parameters:DeprecationWarning
ignore:joblib not installed:RuntimeWarning
ignore:Using a non-tuple sequence for multidimensional indexing:FutureWarning
ignore:using a non-integer number instead of an integer will result in an error:DeprecationWarning
ignore:Importing from numpy.testing.decorators is deprecated:DeprecationWarning
ignore:np.loads is deprecated, use pickle.loads instead:DeprecationWarning
ignore:The oldnumeric module will be dropped:DeprecationWarning
ignore:Collection picker None could not be converted to float:UserWarning
ignore:covariance is not positive-semidefinite:RuntimeWarning
ignore:Can only plot ICA components:RuntimeWarning
ignore:Matplotlib is building the font cache using fc-list:UserWarning
ignore:Using or importing the ABCs from 'collections':DeprecationWarning
ignore:`formatargspec` is deprecated:DeprecationWarning
# This is only necessary until sklearn updates their wheels for NumPy 1.16
ignore:numpy.ufunc size changed:RuntimeWarning
""" # noqa: E501
for warning_line in warning_lines.split('\n'):
warning_line = warning_line.strip()
if warning_line and not warning_line.startswith('#'):
config.addinivalue_line('filterwarnings', warning_line)


@pytest.fixture(scope='session')
def matplotlib_config():
"""Configure matplotlib for viz tests."""
Expand Down Expand Up @@ -73,6 +125,7 @@ def evoked():

@pytest.fixture(scope='function', params=[testing._pytest_param()])
def noise_cov():
"""Get a noise cov from the testing dataset."""
return mne.read_cov(fname_cov)


Expand Down Expand Up @@ -115,11 +168,13 @@ def _bias_params(evoked, noise_cov, fwd):
"pyvista",
])
def backend_name(request):
"""Get the backend name."""
yield request.param


@pytest.yield_fixture
def backends_3d(backend_name):
"""Yield the 3D backends."""
from mne.viz.backends.renderer import _use_test_3d_backend
from mne.viz.backends.tests._utils import has_mayavi, has_pyvista
if backend_name == 'mayavi':
Expand Down
38 changes: 0 additions & 38 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,6 @@ release = egg_info -RDb ''
[bdist_rpm]
doc-files = doc

[tool:pytest]
addopts = --showlocals --durations=20 --doctest-modules -ra --cov-report=
--doctest-ignore-import-errors --junit-xml=junit-results.xml
--ignore=doc --ignore=logo --ignore=examples --ignore=tutorials
--ignore=mne/gui/_*.py
markers =
slowtest
ultraslowtest
usefixtures = matplotlib_config
# Set this pretty low to ensure we do not by default add really long tests,
# or make changes that make things a lot slower
timeout = 30
# Once SciPy updates not to have non-integer and non-tuple errors (1.2.0) we
# should remove them from here.
# This list should also be considered alongside reset_warnings in doc/conf.py
filterwarnings =
error::
ignore::ImportWarning
ignore:the matrix subclass:PendingDeprecationWarning
ignore:numpy.dtype size changed:RuntimeWarning
ignore:.*HasTraits.trait_.*:DeprecationWarning
ignore:.*takes no parameters:DeprecationWarning
ignore:joblib not installed:RuntimeWarning
ignore:Using a non-tuple sequence for multidimensional indexing:FutureWarning
ignore:using a non-integer number instead of an integer will result in an error:DeprecationWarning
ignore:Importing from numpy.testing.decorators is deprecated:DeprecationWarning
ignore:np.loads is deprecated, use pickle.loads instead:DeprecationWarning
ignore:The oldnumeric module will be dropped:DeprecationWarning
ignore:Collection picker None could not be converted to float:UserWarning
ignore:covariance is not positive-semidefinite:RuntimeWarning
ignore:Can only plot ICA components:RuntimeWarning
ignore:Matplotlib is building the font cache using fc-list:UserWarning
ignore:Using or importing the ABCs from 'collections':DeprecationWarning
ignore:`formatargspec` is deprecated:DeprecationWarning
# This is only necessary until sklearn updates their wheels for NumPy 1.16
ignore:numpy.ufunc size changed:RuntimeWarning


[flake8]
exclude = __init__.py,*externals*,constants.py,fixes.py
ignore = E241,E305,W504
Expand Down

0 comments on commit 5bc0a8f

Please sign in to comment.