chore: remove outdated code#6798
Conversation
9272e14 to
c6d642b
Compare
blackboxsw
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
| 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): |
There was a problem hiding this comment.
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"): |
There was a problem hiding this comment.
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.
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.
Proposed Commit Message
Context
Jinja has been imported in cloud-init without error handling since 4f60ff0.
Merge type