diff --git a/tests/helpers/test_helper_utils.py b/tests/helpers/test_helper_utils.py index 7893d25ab..9512a964f 100644 --- a/tests/helpers/test_helper_utils.py +++ b/tests/helpers/test_helper_utils.py @@ -29,6 +29,7 @@ from helpers import utils # pylint: disable=import-error ({'a': [1, 2, 3]}, {'a': [1]}), ({'a': [1, 2, 3]}, {'a': [..., 2]}), (1.0, 1.00000001), + ("foobarbaz", "foo*baz"), ]) def test_partial_compare_equal(val1, val2): assert utils.partial_compare(val1, val2) @@ -43,6 +44,7 @@ def test_partial_compare_equal(val1, val2): ([1], {1: 2}), ({1: 1}, {1: [1]}), ({'a': [1, 2, 3]}, {'a': [..., 3]}), + ("foo*baz", "foobarbaz"), ]) def test_partial_compare_not_equal(val1, val2): assert not utils.partial_compare(val1, val2) diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py index 7af219d77..775d79bf4 100644 --- a/tests/helpers/utils.py +++ b/tests/helpers/utils.py @@ -20,6 +20,9 @@ """Partial comparison of dicts/lists.""" +import fnmatch + + def _partial_compare_dict(val1, val2): for key in val2: if key not in val1: @@ -71,6 +74,9 @@ def partial_compare(val1, val2): elif isinstance(val2, float): print("Doing float comparison") equal = abs(val1 - val2) < 0.00001 + elif isinstance(val2, str): + print("Doing string comparison") + equal = fnmatch.fnmatchcase(val1, val2) else: print("Comparing via ==") equal = val1 == val2