Skip to content

Commit 44c5460

Browse files
elmq0022TomAugspurger
authored andcommitted
TST: Use absolute path for datapath (#21647)
1 parent b35cb1c commit 44c5460

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pandas/conftest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ def datapath(request):
153153
ValueError
154154
If the path doesn't exist and the --strict-data-files option is set.
155155
"""
156+
BASE_PATH = os.path.join(os.path.dirname(__file__), 'tests')
157+
156158
def deco(*args):
157-
path = os.path.join('pandas', 'tests', *args)
159+
path = os.path.join(BASE_PATH, *args)
158160
if not os.path.exists(path):
159161
if request.config.getoption("--strict-data-files"):
160162
msg = "Could not find file {} and --strict-data-files is set."

pandas/tests/util/test_testing.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -852,5 +852,10 @@ def test_datapath_missing(datapath, request):
852852
datapath('not_a_file')
853853

854854
result = datapath('data', 'iris.csv')
855-
expected = os.path.join('pandas', 'tests', 'data', 'iris.csv')
855+
expected = os.path.join(
856+
os.path.dirname(os.path.dirname(__file__)),
857+
'data',
858+
'iris.csv'
859+
)
860+
856861
assert result == expected

0 commit comments

Comments
 (0)