Skip to content

chore: remove outdated code#6798

Merged
blackboxsw merged 3 commits into
canonical:mainfrom
holmanb:holmanb/drop-outdated-code
Mar 26, 2026
Merged

chore: remove outdated code#6798
blackboxsw merged 3 commits into
canonical:mainfrom
holmanb:holmanb/drop-outdated-code

Conversation

@holmanb
Copy link
Copy Markdown
Member

@holmanb holmanb commented Mar 18, 2026

Proposed Commit Message

chore: drop outdated code

The biggest change is dropping jinja2 import handling code and testing
handlers. The jinja2 module has been imported directly in templater.py
since 24.1.

The unit test helper has some additional helpers that can be dropped.

Context

Jinja has been imported in cloud-init without error handling since 4f60ff0.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@holmanb holmanb force-pushed the holmanb/drop-outdated-code branch from 9272e14 to c6d642b Compare March 18, 2026 23:48
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.

LGTM. One minor nit on the from unittest import mock on the one-line you've already touched in this PR.
If you want to automatically refactor any other from tests.unittests.helpers import mock to from unittest import mock as a separate commit. I'd +1 that too. Otherwise I can followup with a separate PR after this lands.

from cloudinit.templater import JinjaSyntaxParsingException
from cloudinit.util import ensure_dir, write_file
from tests.unittests.helpers import mock, skipUnlessJinja
from tests.unittests.helpers import mock
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.

Since we are touching this line, and we aren't providing any additional features necessary beyond the standard library, let's just use unittests.mock

Suggested change
from tests.unittests.helpers import mock
from unittests import mock


# Note: The use of this class and unittests.TestCase is discouraged. Use pytest
# instead. See development docs on testing.
class TestCase(unittest.TestCase):
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.

Whoa, great!. I hadn't realized we had finished landing all the refactors away from TestCase. Long-live pytest.



# older versions of mock do not have the useful 'assert_not_called'
if not hasattr(mock.Mock, "assert_not_called"):
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.

Now that we can drop this supplement to unittest.mock I think we can also avoid any
from tests.unittests.helpers import mock and replace it with:
from unittest import mock.

It doesn't need to be in this PR, but a single supplemental commit dropping those imports would do nicely too.

@blackboxsw blackboxsw self-assigned this Mar 25, 2026
@blackboxsw blackboxsw merged commit 473fa33 into canonical:main Mar 26, 2026
17 checks passed
@holmanb holmanb deleted the holmanb/drop-outdated-code branch March 26, 2026 23:16
blackboxsw pushed a commit to blackboxsw/cloud-init that referenced this pull request Apr 13, 2026
The biggest change is dropping jinja2 import handling code and testing
handlers. The jinja2 module has been imported directly in templater.py
since 24.1.

The unit test helper has some additional helpers that can be dropped as
well as overridden mock imports.
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