Skip to content

Wrong path referenced for failing test #10168

@felixriese

Description

@felixriese

I locally moved my project folder project/ to another directory from /files/old/path/project to /files/new/project. Then, I ran the tests with pytest, which works as expected - except the shown path to a test file when a test fails [output is censored]:

E   AssertionError: assert 'something' == <something_else'>
E     - something
E     ?          ^^
E     + something_else
E     ?          ^^^

/files/old/path/project/tests/test_something.py:30: AssertionError

When I run pytest --vvv, I get:

project/tests/test_something.py::TestName::test_something[SUCCESS-something] <- ../../project/tests/test_something.py FAILED [ 25%]

which shows the relative path to the old directory.

Expected behavior: The old directory is not shown anywhere.


pyproject.toml:

[tool.pytest.ini_options]
minversion = "7.1.2"
addopts = "--cov=app/ --cov-report html --cov-report term"
testpaths = [
    "tests"
]
required_plugins = ["pytest-cov", "pytest-mock"]
pythonpath = ["app"]

Setup on macOS 12.5 (M1):

platform darwin -- Python 3.9.7, pytest-7.1.2, pluggy-1.0.0 -- /Users/name/miniforge3/envs/env-name/bin/python3.9
cachedir: .pytest_cache
django: settings: backend.server.settings (from ini)
rootdir: /files/new/, configfile: pyproject.toml, testpaths: project/tests
plugins: anyio-3.5.0, env-0.6.2, dash-2.5.0, mock-3.8.2, django-4.5.2, cov-3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions