Pytestify tests with unittest.TestCase
Convert tests using unittests.TestCase and the cloud-init custom one to pytest.
- [x] tests/unittests/test_pathprefix2dict.py
- [ ] tests/unittests/config/test_cc_rsyslog.py
- [ ] tests/unittests/config/test_cc_power_state_change.py
- [x] tests/unittests/config/test_apt_conf_v1.py
- [x] tests/unittests/config/test_schema.py
- [ ] tests/unittests/config/test_cc_growpart.py
- [x] tests/unittests/config/test_cc_spacewalk.py
- [ ] tests/unittests/config/test_cc_ca_certs.py
- [x] tests/unittests/config/test_cc_mcollective.py
- [x] tests/unittests/sources/test_openstack.py
- [x] tests/unittests/sources/test_common.py
- [ ] tests/unittests/test_util.py
- [x] tests/unittests/distros/test_resolv.py
- [x] tests/unittests/distros/test_user_data_normalize.py
- [x] tests/unittests/distros/test_hosts.py
- [x] tests/unittests/distros/test_hostname.py
- [x] tests/unittests/distros/test_ifconfig.py
- [x] tests/unittests/distros/test_sysconfig.py
- [x] tests/unittests/distros/test_alpine.py
- [ ] tests/unittests/helpers.py
- [x] tests/unittests/test_registry.py
- [x] tests/unittests/test__init__.py
- [x] tests/unittests/reporting/test_reporting.py
- [x] tests/unittests/test_data.py
Hi team, I’m looking at the PR #6427 to convert tests using unittest.TestCase (and the cloud-init custom test classes) to pytest. I want to clarify a few things before I start:
Should all the listed test files under tests/unittests/ be fully converted to pytest, including config, distros, and helpers?
For the custom cloud-init test classes, do you want them fully rewritten with pytest fixtures, or just drop the base class and convert asserts?
Any specific CI/test requirements to keep in mind while converting? Once I get confirmation, I can start the conversion and open a commit/PR with all changes. Thanks!
Hello, thanks for the interest in making cloud-init better.
It is encouraged to accomplish this issue by small PRs, to ease the work and the review, so please do limit the scope of your PRs.
About fixtures, I would say use them when it makes sense. General testing guidelines: https://cloudinit.readthedocs.io/en/latest/development/testing.html.
Do not hesitate to ask any question. Thanks again!
Thanks for the clarification! To confirm, I’ll start by converting just a small set of files (e.g. 1–2 test files) to pytest and open a PR for review. Once that’s merged, I’ll continue in small batches until the full list from #6427 is covered.
I’ll use fixtures only where it makes sense, and I’ll follow the testing guidelines you shared.
Does that workflow sound good to you?
https://github.com/canonical/cloud-init/pull/6433
Hi @aciba90. Can I possibly join in to handle some of these test conversions? I'm a new contributor
Hi! I’d like to work on this issue for Hacktoberfest by pytestifying the following files:
I’ll keep the scope limited to these two files for this PR.
Hi @aciba90 . I have created a PR for migration of tests/unittests/distros/test_resolv.py to pytest. can you please review it.
Hi @aciba90 I have created a PR for migration of tests/unittests/distros/test_sysconfig.py to pytest. can you please review it.
Hi @aciba90 I have created a PR for migration of tests/unittests/distros/test_hostname.py to pytest. can you please review it.
Hi @aciba90 I have created a PR for migration of tests/unittests/sources/test_common.py to pytest. can you please review it.
Hi @aciba90 I have created a PR for migration of tests/unittests/config/test_cc_spacewalk.py to pytest. can you please review it.
Nice work hacktoberfest contributors. Only a few items left on this mega tech-debt task. Great contributions so far.
Hello, I would like to work on this issue if possible.
Hello, I would like to work on this issue if possible.
@MoeSalah1999 Hey o/ feel free, please do.