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

Speedup utils tests #145

Merged
merged 2 commits into from
Jun 21, 2024
Merged

Speedup utils tests #145

merged 2 commits into from
Jun 21, 2024

Conversation

shrik450
Copy link
Collaborator

Takes tests/test_utils.py from 5 minutes to 5 seconds, and resolves one of the biggest pain points of writing and updating utils tests.

Replaces #127, and part of #29.

This involves two major changes:

  • Use pytest-recording (and indirectly vcr.py) to save network requests made by the tests, which leads to a massive speedup in the run time of the utils tests.
  • Use syrupy to store test data as snapshots instead of manually saving them. This eliminates the manual effort required to manage our test files, making it much more convenient to update existing tests and create new tests.

Since we're going to be changing a lot of test data in the multi-part component combination work, this should go before to make it much faster for me to iterate on that 🙏

Known downsides:

  • Since vcr matches on the name of the repo, the utils tests now create repos with well-known names, and delete those repos at the end of the test. If you interrupt a test, the cleanup might not run and you will have to manually delete those repos for tests to pass.

@shrik450 shrik450 self-assigned this Jun 17, 2024
@shrik450 shrik450 requested a review from a team as a code owner June 17, 2024 19:16
def instance(port):
def instance(port, pytestconfig):
# The None record mode is the default and is equivalent to "once"
if pytestconfig.getoption("record_mode") in ["none", "once", None]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be getoption("--record-mode")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, this gives us an argparse namespace that removes the leading --.

Copy link
Contributor

@kdumontnu kdumontnu left a comment

Choose a reason for hiding this comment

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

👍 Nice for adding the cron job to re-record the casettes

@shrik450 shrik450 merged commit b2f62b6 into main Jun 21, 2024
4 checks passed
@shrik450 shrik450 deleted the su/test-suite-speedup branch June 21, 2024 13:41
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.

3 participants