-
Notifications
You must be signed in to change notification settings - Fork 62
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: unit test execution in PyCharm (#1755) #1756
base: develop
Are you sure you want to change the base?
Conversation
* 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]>
Signed-off-by: d10n <[email protected]>
Signed-off-by: d10n <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there doc/tutorial on how one might take advantage of these changes by, for example, employing PyCharm to debug trestle?
For example in the contributing doc https://oscal-compass.github.io/compliance-trestle/contributing/mkdocs_contributing/ there is info on testing and such.
PyCharm has docs on creating the unit test configuration, but I'll add a short blurb about it to the docs here too |
What I'm after is a way to reproduce the problem and show that it has been fixed. I installed PyCharm (community edition). I downloaded the trestle repo (develop branch). I can Run and Debug for a test script (cis_xlsx_to_oscal_catalog.py), though for the Debug case when I place breakpoints they do not seem to cause a stop - the console message is |
Thanks for the bump - I'll record a short screen recording and attach it here |
relative to the current working directory.
running and debugging tests.
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.
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
Types of changes
develop
->main
)Quality assurance (all should be covered).
Summary
Key links:
Before you merge