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

Use pytest_subtests for grouped tests #2644

Merged
merged 3 commits into from
Sep 25, 2024
Merged

Conversation

mkoura
Copy link
Collaborator

@mkoura mkoura commented Sep 25, 2024

We use custom xdist scheduler and xdist_marker for grouping tests that should run on the same Pytest worker. That is needed e.g. when we want to share expensive setup between several tests.

However in some cases this grouping is not enough. Consider hypothetical scenario where we want to reconfigure dbsync and run several tests with the changed configuration. We wouldn't know if the last marked test already finished, and so we don't know when we can return dbsync to its original configuration. We would need to respin the whole cluster instance (using cluster manager). With subtests approach, we can have a single test where a fixture does the setup (reconfiguration) and teardown (back to original) of the dbsync configuration. All the individual tests are just subtests.

Added pytest-subtests version 0.13.1 to the dependencies in pyproject.toml
and poetry.lock. This package provides unittest subTest() support and
subtests fixture, enhancing the testing capabilities.
Use pytest_subtests for grouped tests that are supposed to run on the
same pytest worker.

- Introduced pytest_subtests to `test_pools.py` and `test_tx_many_utxos.py`
- Refactored `test_stake_pool_cost` to use subtests for different pool costs
- Refactored `test_mini_transactions` to use subtests for different amounts
- Removed xdist_group marker from `TestManyUTXOs` and `TestPoolCost` classes
Added a new test class `TestSubtests` to verify outcomes using subtests.
@mkoura mkoura merged commit ea895e7 into master Sep 25, 2024
4 checks passed
@mkoura mkoura deleted the use_subtest_for_grouped branch September 25, 2024 13:14
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.

1 participant