Skip to content

Commit e41e00f

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 88e063a commit e41e00f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

pandas/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import operator
3131
import os
3232
from typing import Callable
33+
import argparse
3334

3435
from dateutil.tz import (
3536
tzlocal,
@@ -112,6 +113,7 @@ def pytest_addoption(parser) -> None:
112113
action="store_true",
113114
help="Fail if a test is skipped for missing data file.",
114115
)
116+
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
115117

116118

117119
def ignore_doctest_warning(item: pytest.Item, path: str, message: str) -> None:
@@ -1141,7 +1143,7 @@ def strict_data_files(pytestconfig):
11411143

11421144

11431145
@pytest.fixture
1144-
def datapath(strict_data_files: str) -> Callable[..., str]:
1146+
def datapath(strict_data_files: str,pytestconfig) -> Callable[..., str]:
11451147
"""
11461148
Get the path to a data file.
11471149
@@ -1159,7 +1161,9 @@ def datapath(strict_data_files: str) -> Callable[..., str]:
11591161
ValueError
11601162
If the path doesn't exist and the --strict-data-files option is set.
11611163
"""
1162-
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
1164+
BASE_PATH = pytestconfig.getoption("--deb-data-root-dir",default=None)
1165+
if BASE_PATH is None:
1166+
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
11631167

11641168
def deco(*args):
11651169
path = os.path.join(BASE_PATH, *args)

pandas/tests/io/formats/style/test_html.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def tpl_table():
4040
return env.get_template("html_table.tpl")
4141

4242

43+
@pytest.mark.xfail(reason="--deb-data-root-dir is expected to break this",strict=False)
4344
def test_html_template_extends_options():
4445
# make sure if templates are edited tests are updated as are setup fixtures
4546
# to understand the dependency

pandas/tests/util/test_util.py

Lines changed: 1 addition & 0 deletions
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)