diff options
author | Scott Moser <smoser@ubuntu.com> | 2017-07-12 17:16:35 -0700 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-07-19 07:53:10 -0400 |
commit | 865e941f3f88c7daeafbf1eab856e02ce2b6a5f7 (patch) | |
tree | 99342a0c9f32295e5315705f3d36a356bf247aea /tests/unittests/helpers.py | |
parent | d1e8eb73aca6a3f5cee415774dcf540e934ec250 (diff) | |
download | vyos-cloud-init-865e941f3f88c7daeafbf1eab856e02ce2b6a5f7.tar.gz vyos-cloud-init-865e941f3f88c7daeafbf1eab856e02ce2b6a5f7.zip |
tests: fixes for issues uncovered when moving to python 3.6.
This includes a few fixes found when testing with python 3.6.
- fix eni renderer when target is None
This just uses the util.target_path() in the event that target is None.
- change test cases to not rely on the cached result of
util.get_cmdline() and other cached globals. Update the base TestCase
to unset that cache.
- mock calls to system_is_snappy from the create_users test cases.
- drop unused _pp_root in test_simple_run.py
LP: #1703697
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r-- | tests/unittests/helpers.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py index 569f1aef..6691cf82 100644 --- a/tests/unittests/helpers.py +++ b/tests/unittests/helpers.py @@ -82,7 +82,26 @@ def retarget_many_wrapper(new_base, am, old_func): class TestCase(unittest2.TestCase): - pass + def reset_global_state(self): + """Reset any global state to its original settings. + + cloudinit caches some values in cloudinit.util. Unit tests that + involved those cached paths were then subject to failure if the order + of invocation changed (LP: #1703697). + + This function resets any of these global state variables to their + initial state. + + In the future this should really be done with some registry that + can then be cleaned in a more obvious way. + """ + util.PROC_CMDLINE = None + util._DNS_REDIRECT_IP = None + util._LSB_RELEASE = {} + + def setUp(self): + super(unittest2.TestCase, self).setUp() + self.reset_global_state() class CiTestCase(TestCase): |