Skip to content

Commit 3f83627

Browse files
simonjayhawkinsjreback
authored andcommitted
test_datapath_missing (pandas-dev#24481)
1 parent fe696e4 commit 3f83627

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pandas/conftest.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ def join_type(request):
275275

276276

277277
@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):
279284
"""Get the path to a data file.
280285
281286
Parameters
@@ -297,7 +302,7 @@ def datapath(request):
297302
def deco(*args):
298303
path = os.path.join(BASE_PATH, *args)
299304
if not os.path.exists(path):
300-
if request.config.getoption("--strict-data-files"):
305+
if strict_data_files:
301306
msg = "Could not find file {} and --strict-data-files is set."
302307
raise ValueError(msg.format(path))
303308
else:

pandas/tests/util/test_util.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ def test_assert_raises_regex_deprecated():
100100
assert 1 == 2, msg
101101

102102

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):
107105
with pytest.raises(ValueError, match="Could not find file"):
108106
datapath("not_a_file")
109107

108+
109+
def test_datapath(datapath):
110110
args = ("data", "iris.csv")
111111

112112
result = datapath(*args)

0 commit comments

Comments
 (0)