From: Debian Science Team Date: Mon, 7 Dec 2020 23:06:28 +0000 (+0000) Subject: Allow tests to use the data files in the source tree X-Git-Tag: archive/raspbian/1.5.3+dfsg-2+rpi1~1^2^2^2^2^2^2^2^2^2^2^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=68bb03789032257f16e2d7305021c34b3299b4da;p=pandas.git 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 Forwarded: not-needed Gbp-Pq: Name find_test_data.patch --- diff --git a/pandas/conftest.py b/pandas/conftest.py index 74cab2e0..7bf4f4be 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -23,6 +23,7 @@ from datetime import date, time, timedelta, timezone from decimal import Decimal import operator import os +import argparse from dateutil.tz import tzlocal, tzutc import hypothesis @@ -70,6 +71,7 @@ def pytest_addoption(parser): action="store_true", help="Fail if a test is skipped for missing data file.", ) + 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 def pytest_runtest_setup(item): @@ -785,7 +787,7 @@ def strict_data_files(pytestconfig): @pytest.fixture -def datapath(strict_data_files): +def datapath(strict_data_files,pytestconfig): """ Get the path to a data file. @@ -803,7 +805,9 @@ def datapath(strict_data_files): 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") + BASE_PATH = pytestconfig.getoption("--deb-data-root-dir",default=None) + if BASE_PATH is None: + BASE_PATH = os.path.join(os.path.dirname(__file__), "tests") def deco(*args): path = os.path.join(BASE_PATH, *args) diff --git a/pandas/tests/util/test_util.py b/pandas/tests/util/test_util.py index d73a789b..8d693e73 100644 --- a/pandas/tests/util/test_util.py +++ b/pandas/tests/util/test_util.py @@ -57,6 +57,7 @@ def test_datapath_missing(datapath): datapath("not_a_file") +@pytest.mark.xfail(reason="--deb-data-root-dir intentionally breaks this",strict=False) def test_datapath(datapath): args = ("io", "data", "csv", "iris.csv")