Skip to content

Test fixture datapath uses relative instead of absoulte file paths #21646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
elmq0022 opened this issue Jun 26, 2018 · 0 comments · Fixed by #21647
Closed

Test fixture datapath uses relative instead of absoulte file paths #21646

elmq0022 opened this issue Jun 26, 2018 · 0 comments · Fixed by #21647

Comments

@elmq0022
Copy link
Contributor

elmq0022 commented Jun 26, 2018

The following code in pandas/blob/master/pandas/conftest.py uses a relative vs absolute path.

@pytest.fixture
def datapath(request):
    """Get the path to a data file.
    Parameters
    ----------
    path : str
        Path to the file, relative to ``pandas/tests/``
    Returns
    -------
    path : path including ``pandas/tests``.
    Raises
    ------
    ValueError
        If the path doesn't exist and the --strict-data-files option is set.
    """
    def deco(*args):
        path = os.path.join('pandas', 'tests', *args)
        if not os.path.exists(path):
            if request.config.getoption("--strict-data-files"):
                msg = "Could not find file {} and --strict-data-files is set."
                raise ValueError(msg.format(path))
            else:
                msg = "Could not find {}."
                pytest.skip(msg.format(path))
        return path
    return deco

This means that the test runner must be run from the root of the project directory which could be inconvenient when running tests in a specific directory.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: 36422a8 python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-23-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.24.0.dev0+170.g36422a884
pytest: 3.6.2
pip: 10.0.1
setuptools: 39.2.0
Cython: 0.28.3
numpy: 1.14.5
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: 1.7.5
patsy: None
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 26, 2018
elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant