Skip to content

test (config): Convert test_apt_conf_v1.py from unittest to pytest#6520

Merged
blackboxsw merged 3 commits into
canonical:mainfrom
csemanish12:pytest-apt-conf-v1-migration
Oct 22, 2025
Merged

test (config): Convert test_apt_conf_v1.py from unittest to pytest#6520
blackboxsw merged 3 commits into
canonical:mainfrom
csemanish12:pytest-apt-conf-v1-migration

Conversation

@csemanish12
Copy link
Copy Markdown
Contributor

Refactored tests/unittests/config/test_apt_conf_v1.py to use pytest instead of unittest.TestCase as part of the pytest migration effort.

  • Removed unittest.TestCase inheritance
  • Converted setUp() to pytest fixture for temporary files
  • Parameterized proxy-related tests for cleaner duplication removal
  • Replaced unittest assertions with plain pytest assert statements
  • Replaced _search_apt_config as standalone helper function
  • Maintained all original test functionality

Related: #6427

Refactored tests/unittests/config/test_apt_conf_v1.py to use pytest instead of unittest.TestCase as part of the pytest migration effort.

  - Removed unittest.TestCase inheritance
  - Converted setUp() to pytest fixture for temporary files
  - Parameterized proxy-related tests for cleaner duplication removal
  - Replaced unittest assertions with plain pytest `assert` statements
  - Replaced `_search_apt_config` as standalone helper function
  - Maintained all original test functionality

 Related: canonical#6427
@csemanish12 csemanish12 changed the title Pytest apt conf v1 migration test (config): Convert test_apt_conf_v1.py from unit test to pytest Oct 19, 2025
@csemanish12 csemanish12 changed the title test (config): Convert test_apt_conf_v1.py from unit test to pytest test (config): Convert test_apt_conf_v1.py from unittest to pytest Oct 19, 2025
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

Looks great. Minor spelling nits throughout test_apt_conf_v1.py as we recently had a PR fixing spelling mistakes in comments/tests etc.


def test_proxy_replaced(self, p_c_files):
pfile, cfile = p_c_files
util.write_file(cfile, "content doesnt matter")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

minor spelling nit.
doesn't


def test_proxy_deleted(self, p_c_files):
pfile, cfile = p_c_files
util.write_file(cfile, "content doesnt matter")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

minor spelling nit while we are here.
doesn't

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

Ship it.

@blackboxsw blackboxsw merged commit bde544c into canonical:main Oct 22, 2025
21 checks passed
blackboxsw pushed a commit to blackboxsw/cloud-init that referenced this pull request Dec 12, 2025
…anonical#6520)

Refactored tests/unittests/config/test_apt_conf_v1.py to
use pytest instead of unittest.TestCase as part of the pytest
migration effort.

- Removed unittest.TestCase inheritance
- Converted setUp() to pytest fixture for temporary files
- Parameterized proxy-related tests for cleaner duplication removal
- Replaced unittest assertions with plain pytest `assert` statements
- Replaced `_search_apt_config` as standalone helper function
- Maintained all original test functionality

Related: canonical#6427
holmanb pushed a commit that referenced this pull request Dec 18, 2025
…6520)

Refactored tests/unittests/config/test_apt_conf_v1.py to
use pytest instead of unittest.TestCase as part of the pytest
migration effort.

- Removed unittest.TestCase inheritance
- Converted setUp() to pytest fixture for temporary files
- Parameterized proxy-related tests for cleaner duplication removal
- Replaced unittest assertions with plain pytest `assert` statements
- Replaced `_search_apt_config` as standalone helper function
- Maintained all original test functionality

Related: #6427
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.

2 participants