unit tests: move to pytest
Metadata
Current evaluation
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.
Suggested action: —
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 |
|---|---|---|---|---|
| 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Migrated all unit tests from unittest and testscenarios to pytest, introducing fixtures and parametrization. Updated runtests.sh to use pytest-cov while retaining unittest for integration tests. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #167 tests: move test module from unit/ to integration/ | craft-cli | merged | Merged the move of test_messages_integration from unit/ to integration/. Updated coverage to include integration tests, disabled the local fail_under check, and relies on GitHub coverage. Approved and passed CI. |