File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 2
2
import numpy
3
3
import os
4
4
5
+ DATADIR = os .path .realpath (
6
+ os .path .join (os .path .dirname (__file__ ), 'testing/data' ))
7
+
5
8
6
9
@pytest .fixture (autouse = True )
7
10
def add_np (doctest_namespace ):
8
11
doctest_namespace ['np' ] = numpy
9
12
doctest_namespace ['os' ] = os
10
13
11
- filepath = os .path .dirname (os .path .realpath (__file__ ))
12
- datadir = os .path .realpath (os .path .join (filepath , 'testing/data' ))
13
- doctest_namespace ["datadir" ] = datadir
14
+ doctest_namespace ["datadir" ] = DATADIR
14
15
15
16
16
- @pytest .fixture (scope = 'session' , autouse = True )
17
- def in_testing ():
18
- datadir = os .path .realpath (
19
- os .path .join (os .path .dirname (__file__ ), 'testing/data' ))
20
- origdir = os .getcwd ()
21
- os .chdir (datadir )
22
- yield
23
- os .chdir (origdir )
17
+ @pytest .fixture (autouse = True )
18
+ def in_testing (request ):
19
+ # This seems to be a reliable way to distinguish tests from doctests
20
+ if request .function is None :
21
+ os .chdir (DATADIR )
You can’t perform that action at this time.
0 commit comments