Skip to content

Commit 17a3a65

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 cb9e9c7 commit 17a3a65

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/conftest.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from decimal import Decimal
44
import operator
55
import os
6+
import argparse
67

78
from dateutil.tz import tzlocal, tzutc
89
import hypothesis
@@ -44,6 +45,7 @@ def pytest_addoption(parser):
4445
action="store_true",
4546
help="Fail if a test is skipped for missing data file.",
4647
)
48+
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
4749

4850

4951
def pytest_runtest_setup(item):
@@ -362,7 +364,7 @@ def strict_data_files(pytestconfig):
362364

363365

364366
@pytest.fixture
365-
def datapath(strict_data_files):
367+
def datapath(strict_data_files,pytestconfig):
366368
"""
367369
Get the path to a data file.
368370
@@ -380,7 +382,9 @@ def datapath(strict_data_files):
380382
ValueError
381383
If the path doesn't exist and the --strict-data-files option is set.
382384
"""
383-
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
385+
BASE_PATH = pytestconfig.getoption("--deb-data-root-dir",default=None)
386+
if BASE_PATH is None:
387+
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
384388

385389
def deco(*args):
386390
path = os.path.join(BASE_PATH, *args)

pandas/tests/util/test_util.py

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_datapath_missing(datapath):
5757
datapath("not_a_file")
5858

5959

60+
@pytest.mark.xfail(reason="--deb-data-root-dir intentionally breaks this",strict=False)
6061
def test_datapath(datapath):
6162
args = ("io", "data", "csv", "iris.csv")
6263

0 commit comments

Comments
 (0)