Allow tests to use the data files in the source tree
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Thu, 9 Apr 2020 03:11:32 +0000 (04:11 +0100)
committerPeter Michael Green <plugwash@raspbian.org>
Thu, 9 Apr 2020 03:11:32 +0000 (04:11 +0100)
We don't ship these in the package,
but do want to run the tests that use them

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: not-needed

Gbp-Pq: Name find_test_data.patch

pandas/conftest.py
pandas/tests/util/test_util.py

index 2cf7bf6a6df41ca5da72525e6dedbd3db23c2380..65571706ad710de3659c688e579cde331c48a4e7 100644 (file)
@@ -2,6 +2,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
@@ -43,6 +44,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):
@@ -340,7 +342,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.
 
     Parameters
@@ -357,7 +359,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)
index 83d9be1ad235f603b01483f58c34c1a5807c4af9..e21ef435750ab3a8408122573c63614d6b6dade4 100644 (file)
@@ -86,6 +86,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 = ("data", "iris.csv")