diff options
author | Daniel Watkins <oddbloke@ubuntu.com> | 2020-11-17 16:55:55 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 14:55:55 -0700 |
commit | e1bde919923ff1f9d1d197f64ea43b976f034062 (patch) | |
tree | 5dffa105fb1e57cdc1e67d8f6eae7e07c33c0f5d /cloudinit | |
parent | 4f2da1cc1d24cbc47025cc8613c0d3ec287a20f9 (diff) | |
download | vyos-cloud-init-e1bde919923ff1f9d1d197f64ea43b976f034062.tar.gz vyos-cloud-init-e1bde919923ff1f9d1d197f64ea43b976f034062.zip |
test_persistence: add VersionIsPoppedFromState test (#673)
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/tests/test_persistence.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cloudinit/tests/test_persistence.py b/cloudinit/tests/test_persistence.py index 7b64ced9..3e5eaa8d 100644 --- a/cloudinit/tests/test_persistence.py +++ b/cloudinit/tests/test_persistence.py @@ -99,6 +99,16 @@ class VersionDefaultsToZero(CloudInitPickleMixin, metaclass=_Collector): assert 0 == ci_pkl_version +class VersionIsPoppedFromState(CloudInitPickleMixin, metaclass=_Collector): + """Test _ci_pkl_version is popped from state before being restored.""" + + def _unpickle(self, ci_pkl_version: int) -> None: + # `self._ci_pkl_version` returns the type's _ci_pkl_version if it isn't + # in instance state, so we need to explicitly check self.__dict__. + sentinel = mock.sentinel.default + assert self.__dict__.get("_ci_pkl_version", sentinel) == sentinel + + class TestPickleMixin: def test_unpickle_called(self): """Test that self._unpickle is called on unpickle.""" |