Skip to content

Commit fcf5f8b

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Allow tests to use the data files in the source tree
We don't ship these in the package, but do want to run the tests that use them Author: Rebecca N. Palmer <[email protected]> Forwarded: not-needed Gbp-Pq: Name find_test_data.patch
1 parent e9a0e55 commit fcf5f8b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from decimal import Decimal
33
import operator
44
import os
5+
import argparse
56

67
from dateutil.tz import tzlocal, tzutc
78
import hypothesis
@@ -43,6 +44,7 @@ def pytest_addoption(parser):
4344
action="store_true",
4445
help="Fail if a test is skipped for missing data file.",
4546
)
47+
parser.addoption("--deb-data-root-dir",action="store",help=argparse.SUPPRESS)#for internal use of the Debian CI infrastructure, may change without warning. Security note: test_pickle can run arbitrary code from this directory
4648

4749

4850
def pytest_runtest_setup(item):
@@ -340,7 +342,7 @@ def strict_data_files(pytestconfig):
340342

341343

342344
@pytest.fixture
343-
def datapath(strict_data_files):
345+
def datapath(strict_data_files,pytestconfig):
344346
"""Get the path to a data file.
345347
346348
Parameters
@@ -357,7 +359,9 @@ def datapath(strict_data_files):
357359
ValueError
358360
If the path doesn't exist and the --strict-data-files option is set.
359361
"""
360-
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
362+
BASE_PATH = pytestconfig.getoption("--deb-data-root-dir",default=None)
363+
if BASE_PATH is None:
364+
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
361365

362366
def deco(*args):
363367
path = os.path.join(BASE_PATH, *args)

pandas/tests/util/test_util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def test_datapath_missing(datapath):
8686
datapath("not_a_file")
8787

8888

89+
@pytest.mark.xfail(reason="--deb-data-root-dir intentionally breaks this",strict=False)
8990
def test_datapath(datapath):
9091
args = ("data", "iris.csv")
9192

0 commit comments

Comments
 (0)