File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -275,7 +275,12 @@ def join_type(request):
275
275
276
276
277
277
@pytest .fixture
278
- def datapath (request ):
278
+ def strict_data_files (pytestconfig ):
279
+ return pytestconfig .getoption ("--strict-data-files" )
280
+
281
+
282
+ @pytest .fixture
283
+ def datapath (strict_data_files ):
279
284
"""Get the path to a data file.
280
285
281
286
Parameters
@@ -297,7 +302,7 @@ def datapath(request):
297
302
def deco (* args ):
298
303
path = os .path .join (BASE_PATH , * args )
299
304
if not os .path .exists (path ):
300
- if request . config . getoption ( "--strict-data-files" ) :
305
+ if strict_data_files :
301
306
msg = "Could not find file {} and --strict-data-files is set."
302
307
raise ValueError (msg .format (path ))
303
308
else :
Original file line number Diff line number Diff line change @@ -100,13 +100,13 @@ def test_assert_raises_regex_deprecated():
100
100
assert 1 == 2 , msg
101
101
102
102
103
- def test_datapath_missing (datapath , request ):
104
- if not request .config .getoption ("--strict-data-files" ):
105
- pytest .skip ("Need to set '--strict-data-files'" )
106
-
103
+ @pytest .mark .parametrize ('strict_data_files' , [True , False ])
104
+ def test_datapath_missing (datapath ):
107
105
with pytest .raises (ValueError , match = "Could not find file" ):
108
106
datapath ("not_a_file" )
109
107
108
+
109
+ def test_datapath (datapath ):
110
110
args = ("data" , "iris.csv" )
111
111
112
112
result = datapath (* args )
You can’t perform that action at this time.
0 commit comments