Skip to content
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

Fix use of FakeRepository in tests that change current dir #1517

Merged
merged 1 commit into from
Oct 27, 2021

Conversation

richafrank
Copy link
Contributor

@richafrank richafrank commented Oct 22, 2021

outside of the repo root, e.g. via tmpdir_cwd,
or when running any test from a different working dir.

Uses the absolute path instead of relative.

I encountered this on a branch (not ready yet) where I was starting to use both fixtures in a single test:

test setup failed
@pytest.fixture
    def repository():
>       return FakeRepository()

.../pip-tools/tests/conftest.py:136: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.conftest.FakeRepository object at 0x103893460>

    def __init__(self):
>       with open("tests/test_data/fake-index.json") as f:
E       FileNotFoundError: [Errno 2] No such file or directory: 'tests/test_data/fake-index.json'

.../pip-tools/tests/conftest.py:41: FileNotFoundError
Contributor checklist
  • Provided the tests for the changes. (Existing tests still pass.)
  • Assure PR title is short, clear, and good to be included in the user-oriented changelog
Maintainer checklist
  • Assure one of these labels is present: backwards incompatible, feature, enhancement, deprecation, bug, dependency, docs or skip-changelog as they determine changelog listing.
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

outside of the repo root, e.g. via tmpdir_cwd,
or when running any test from a different working dir.
Copy link
Contributor

@AndydeCleyre AndydeCleyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, deterministic paths are definitely an improvement.

@atugushev atugushev merged commit dc80b95 into jazzband:master Oct 27, 2021
@atugushev atugushev added skip-changelog Avoid listing in changelog tests Testing and related things labels Oct 27, 2021
@richafrank richafrank deleted the cur-dir-agnostic branch October 27, 2021 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Avoid listing in changelog tests Testing and related things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants