diff options
author | Erik Skultety <eskultet@redhat.com> | 2023-03-29 14:34:11 +0200 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2023-03-30 08:00:42 +0000 |
commit | e35d7a415a256053bb999848ad11680f691fd708 (patch) | |
tree | ae19fcdd1803fd255e60bb502e52f4f8247ed81b | |
parent | 49262843e7e02736cc482a2434bcd20676a42909 (diff) | |
download | libvirt-ci-e35d7a415a256053bb999848ad11680f691fd708.zip libvirt-ci-e35d7a415a256053bb999848ad11680f691fd708.tar.gz libvirt-ci-e35d7a415a256053bb999848ad11680f691fd708.tar.bz2 |
tests: utils: Introduce a diff abstraction class
Signed-off-by: Erik Skultety <eskultet@redhat.com>
-rw-r--r-- | tests/test_utils/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_utils/utils.py b/tests/test_utils/utils.py index edfb72d..f22946b 100644 --- a/tests/test_utils/utils.py +++ b/tests/test_utils/utils.py @@ -60,6 +60,21 @@ def assert_equal_list(actual, expected, indices, kind): raise AssertionError(len_err) +class Diff: + def __init__(self, diffobj): + self._obj = diffobj + self.diff = "".join(diffobj) + + def __repr__(self): + return f"obj: {repr(self._diffobj)}, str: {self.diff}" + + def __str__(self): + return self.diff + + def empty(self): + return not bool(str(self)) + + def assert_equal(actual, expected, indices): if not isinstance(actual, type(expected)): raise AssertionError(format_err_msg(indices, f"expected {type(expected)}, got {type(actual)}")) |