unit tests: move to pytest
Metadata
Current evaluation
Merged PR #3167 in commit 788475f62, migrating unit tests from testscenarios to pytest, adding fixtures and pytest-cov, and retaining unittest for integration tests.
Resolution: closed resolved
Reason: PR #3167 was merged as commit 788475f62. It migrated unit tests and test execution to pytest and pytest-cov while keeping unittest for integration tests.
Evaluated by: mr-cal-bot
No scores available.
Issue body
All tests have been migrated to work with pytest.
This means that testscenarios as such is not longer being used for unit
tests and using a shim that parametrizes tests for pytest.
For the cases where the unit.TestCase was to ingrained in the test, the
strategy to replace scenarios has been to go with test duplication. This
has the benefit that testscenarios removed where it is now possible to
run an individual test.
pytest specific fixtures were added to better support some test cases.
Most tests are unchanged, but would benefit from smaller fixtures as
those added by pytest for faster test setup.
runtests.sh has been adapted to use pytest with pytest-cov, but keeping
unittest as the runner for integration tests.
The spread tests were also updated, but it would be good to see them not
run in spread anymore.
Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3167 in commit 788475f62, migrating unit tests from testscenarios to pytest, adding fixtures and pytest-cov, and retaining unittest for integration tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3167 (commit 788475f62) moved snapcraft's unit tests from testscenarios/unittest to pytest, adding pytest fixtures and pytest-cov to runtests.sh while keeping unittest for integration tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3167 in commit 788475f62, migrating unit tests from testscenarios to pytest, adding fixtures and pytest-cov, and retaining unittest for integration tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3167 (commit 788475f62) migrated snapcraft unit tests from testscenarios to pytest, replacing scenarios with a pytest parametrization shim plus test duplication, adding pytest fixtures and pytest-cov in runtests.sh, while keeping unittest for integration tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3167 in commit 788475f62, migrating unit tests from testscenarios to pytest, adding pytest fixtures and pytest-cov, and retaining unittest for integration tests. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged unit test migration from unittest to pytest. Adds pytest fixtures, updates runtests.sh to use pytest-cov, and duplicates tests for individual execution. Integration tests remain on unittest. Approved and merged after CI passed. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged migration of unit tests from testscenarios and unittest to pytest. Updated runtests.sh to use pytest with pytest-cov, added pytest fixtures, and duplicated tests to remove testscenarios. Integration tests remain on unittest. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3162 tests: remove scenario usage from lifecycle order | snapcraft | merged | Merged as commit 58c66b7a7, dropping testscenarios usage from the lifecycle-order unit tests as groundwork for the move to pytest, which landed separately in #3167. | |
| #2176 [WIP] tests: use pytest as test runner | snapcraft | closed | WIP PR to run snapcraft unit tests with pytest (+xdist) sat idle and was closed unmerged; the migration later landed in #3167 (788475f62) after #3162 dropped testscenarios. | |
| #1551 tests (templates): Use pytest fixtures and asserts instead of unittest | charmcraft | merged | Merged in PR #1551 via commit daf5a5b9, migrating template tests from unittest to pytest fixtures and plain assertions. |