Skip to content

TST: don't skip test_datapath_missing if not --strict-data-files #24481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,12 @@ def join_type(request):


@pytest.fixture
def datapath(request):
def strict_data_files(pytestconfig):
return pytestconfig.getoption("--strict-data-files")


@pytest.fixture
def datapath(strict_data_files):
"""Get the path to a data file.

Parameters
Expand All @@ -297,7 +302,7 @@ def datapath(request):
def deco(*args):
path = os.path.join(BASE_PATH, *args)
if not os.path.exists(path):
if request.config.getoption("--strict-data-files"):
if strict_data_files:
msg = "Could not find file {} and --strict-data-files is set."
raise ValueError(msg.format(path))
else:
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/util/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def test_assert_raises_regex_deprecated():
assert 1 == 2, msg


def test_datapath_missing(datapath, request):
if not request.config.getoption("--strict-data-files"):
pytest.skip("Need to set '--strict-data-files'")

@pytest.mark.parametrize('strict_data_files', [True, False])
def test_datapath_missing(datapath):
with pytest.raises(ValueError, match="Could not find file"):
datapath("not_a_file")


def test_datapath(datapath):
args = ("data", "iris.csv")

result = datapath(*args)
Expand Down