Skip to content

WIP: Speed up non-3D tests#7198

Closed
larsoner wants to merge 1 commit intomne-tools:masterfrom
larsoner:conftest
Closed

WIP: Speed up non-3D tests#7198
larsoner wants to merge 1 commit intomne-tools:masterfrom
larsoner:conftest

Conversation

@larsoner
Copy link
Copy Markdown
Member

I've noticed that, even if an individual test is fast, doing:

pytest mne/tests/test_... -k ...

will take some seconds. This is because, at least on my laptop, I get:

$ time pytest mne/utils/tests/test_bunch.py 
Test session starts (platform: darwin, Python 3.7.3, pytest 5.2.0, pytest-sugar 0.9.2)
rootdir: /Users/larsoner/python/mne-python, inifile: setup.cfg
plugins: astropy-header-0.1.1, arraydiff-0.3, sugar-0.9.2, remotedata-0.3.2, timeout-1.3.3, openfiles-0.4.0, mock-1.11.0, cov-2.7.1, doctestplus-0.5.0
collecting ... 
 mne/utils/tests/test_bunch.py ✓                                                                                                                                     100% ██████████
----------------------------------------------------- generated xml file: /Users/larsoner/python/mne-python/junit-results.xml ------------------------------------------------------
============================================================================ slowest 20 test durations =============================================================================
2.12s setup    mne/utils/tests/test_bunch.py::test_pickle

(0.00 durations hidden.  Use -vv to show these durations.)

Results (2.15s):
       1 passed

real	0m4.822s

On this PR I get:

$ time pytest mne/utils/tests/test_bunch.py 
... 
 mne/utils/tests/test_bunch.py ✓                                                                                                                                     100% ██████████
----------------------------------------------------- generated xml file: /Users/larsoner/python/mne-python/junit-results.xml ------------------------------------------------------
============================================================================ slowest 20 test durations =============================================================================
0.22s setup    mne/utils/tests/test_bunch.py::test_pickle

(0.00 durations hidden.  Use -vv to show these durations.)

Results (0.26s):
       1 passed

real	0m2.276s

@GuillaumeFavelier would you be up for taking over and ensuring that all tests that require the 3D backends make use of this? For example not everything uses renderer, such as test_plot_vec_source_estimates, so we might need to create some new fixture and pass it to those tests until they do. If it's not clear or you are not enthusiastic about doing it I can give it a shot.

This 2 sec overhead may seem trivial, but when doing TDD and iterating in code it gets annoying, so whatever we can do to get good speed gains is beneficial in the long run.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 13, 2020

Codecov Report

Merging #7198 into master will increase coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #7198      +/-   ##
==========================================
+ Coverage   89.77%   89.77%   +<.01%     
==========================================
  Files         445      445              
  Lines       79874    79874              
  Branches    12773    12773              
==========================================
+ Hits        71704    71706       +2     
+ Misses       5372     5368       -4     
- Partials     2798     2800       +2

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant