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

Enable running unit tests in PyCharm #1755

Open
d10n opened this issue Nov 19, 2024 · 0 comments · May be fixed by #1756
Open

Enable running unit tests in PyCharm #1755

d10n opened this issue Nov 19, 2024 · 0 comments · May be fixed by #1756

Comments

@d10n
Copy link
Contributor

d10n commented Nov 19, 2024

Issue description / feature objectives

  • PyCharm has quirks related to the current working directory when running and debugging tests.
  • Tests use pathlib.Path('tests/data') frequently. Where does that resolve the path from? Relative to the current working directory.
  • Where is the tests/data directory? Relative to the tests.
  • Therefore, PyCharm does not have integrated test running and debugging.

Caveats / Assumptions

Completion Criteria

  • Unit tests should pass in the PyCharm test runner, and in all the execution environments they originally passed in too.
d10n added a commit to d10n/compliance-trestle that referenced this issue Nov 19, 2024
* Where does pathlib.Path('tests/data') resolve the path from? It's
  relative to the current working directory.
* Where is the tests/data directory? Relative to the tests.
* PyCharm has quirks related to the current working directory when
  running and debugging tests.
* By using __file__ to resolve the test data directory, we remove the
  non-guaranteed assumption that the current working directory is always
  at the root of the repository, and we replace that assumption with a
  value that is always correct regardless of current working directory.
* As a result, the unit tests can now be debugged in PyCharm, unit tests
  can be executed from any directory, and test execution continues to
  work in all the places it originally worked.

Some of the handling is slightly messy but that can be cleaned up by
making the task config files themselves not dependent on the CWD

Signed-off-by: d10n <[email protected]>
@jpower432 jpower432 linked a pull request Nov 21, 2024 that will close this issue
11 tasks
@butler54 butler54 moved this from New to In review in Trestle Roadmap Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging a pull request may close this issue.

1 participant