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

test(fixtures): cache the base example project directory #799

Conversation

codejedi365
Copy link
Contributor

Purpose

Improve speed of test code and reduce the number of IO operations

Rationale

In other development towards changelog testing, I came across the high use of IO operations as we rebuild a project with each test case. This causes a lot of IO operations, and even more so on the use of git. I followed the rabbit hole, and this PR is the first of a few that help increase the test execution speed through deliberate abstraction/modularity. I felt it all at once would be way to confusing and too much for a good review.

How I tested

Besides checking the result here in the CI, I originally was able to confirm the caching mechanism through the VSCode debugger and many break points through the code to see how many times each fixture was called. Once this commit was implemented, the session scope ensured that it was only called once but the init fixture called every test run.

How to Verify

To get VSCode to run the debugger, you have to change the tool.pytest.ini_options.addopts by removing the --cov* options and then changing -nauto to -n0. Once you do this, add a breakpoint to the start of init_example_project, and cached_example_project. Then execute a test (a minimum of 2 that use init_example_project) with the debugger. When you step through, you will see how many times each is called, and you will see the cleanup occur as well if you put a few breakpoints in teardown_cached_dir.

@codejedi365 codejedi365 force-pushed the test/add-caching-to-example-proj-fixture branch 2 times, most recently from 58c0883 to b333120 Compare January 9, 2024 05:24

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@codejedi365 codejedi365 force-pushed the test/add-caching-to-example-proj-fixture branch from b333120 to 9461ce9 Compare January 13, 2024 01:34
@codejedi365
Copy link
Contributor Author

@bernardcooke53, pr ready for review for when you have time, thanks!

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Contributor

@bernardcooke53 bernardcooke53 left a comment

Choose a reason for hiding this comment

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

I like this a lot @codejedi365, the amount of IO was always quite intense - I'm finding it painfully slow to work on a Mac with the tests on master. Thanks!

@bernardcooke53 bernardcooke53 merged commit 229c647 into python-semantic-release:master Feb 6, 2024
7 checks passed
@codejedi365 codejedi365 deleted the test/add-caching-to-example-proj-fixture branch February 7, 2024 01:05
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 this pull request may close these issues.

None yet

2 participants