diff --git a/pandas/conftest.py b/pandas/conftest.py index 82d860b091b82..5b9c162a0a022 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -153,8 +153,10 @@ def datapath(request): ValueError If the path doesn't exist and the --strict-data-files option is set. """ + BASE_PATH = os.path.join(os.path.dirname(__file__), 'tests') + def deco(*args): - path = os.path.join('pandas', 'tests', *args) + path = os.path.join(BASE_PATH, *args) if not os.path.exists(path): if request.config.getoption("--strict-data-files"): msg = "Could not find file {} and --strict-data-files is set." diff --git a/pandas/tests/util/test_testing.py b/pandas/tests/util/test_testing.py index 4d34987e14f75..95ea4658212e9 100644 --- a/pandas/tests/util/test_testing.py +++ b/pandas/tests/util/test_testing.py @@ -852,5 +852,10 @@ def test_datapath_missing(datapath, request): datapath('not_a_file') result = datapath('data', 'iris.csv') - expected = os.path.join('pandas', 'tests', 'data', 'iris.csv') + expected = os.path.join( + os.path.dirname(os.path.dirname(__file__)), + 'data', + 'iris.csv' + ) + assert result == expected