From dda46ee3cf32acb0b63f23451c56ba09f03eb456 Mon Sep 17 00:00:00 2001 From: Vinay M <63404819+roverflow@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:47:07 +0530 Subject: [PATCH] Fixes tests that use AnsibleUndefined (#383) * Fixes tests that use AnsibleUndefined * add change log * add same for other cases --- changelogs/fragments/test_ansibleundefined.yaml | 3 +++ tests/unit/plugins/filter/test_ipaddr.py | 3 ++- tests/unit/plugins/filter/test_ipv4.py | 3 ++- tests/unit/plugins/filter/test_ipv6.py | 3 ++- tests/unit/plugins/filter/test_ipwrap.py | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/test_ansibleundefined.yaml diff --git a/changelogs/fragments/test_ansibleundefined.yaml b/changelogs/fragments/test_ansibleundefined.yaml new file mode 100644 index 00000000..9f9d5f30 --- /dev/null +++ b/changelogs/fragments/test_ansibleundefined.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fixes test cases where there were assertion failure due to AnsibleUndefined path being changed. diff --git a/tests/unit/plugins/filter/test_ipaddr.py b/tests/unit/plugins/filter/test_ipaddr.py index 2849fb85..152e6689 100644 --- a/tests/unit/plugins/filter/test_ipaddr.py +++ b/tests/unit/plugins/filter/test_ipaddr.py @@ -70,7 +70,8 @@ def test_ipaddr_undefined_value(self): args = ["", AnsibleUndefined(name="my_ip"), ""] with pytest.raises( AnsibleFilterError, - match="Unrecognized type <> for ipaddr filter ", + # Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15 + match=r"Unrecognized type <> for ipaddr filter ", ): _ipaddr(*args) diff --git a/tests/unit/plugins/filter/test_ipv4.py b/tests/unit/plugins/filter/test_ipv4.py index 130ef6ed..f3bdeafe 100644 --- a/tests/unit/plugins/filter/test_ipv4.py +++ b/tests/unit/plugins/filter/test_ipv4.py @@ -50,7 +50,8 @@ def test_ipv4_undefined_value(self): args = ["", AnsibleUndefined(name="my_ip"), ""] with pytest.raises( AnsibleFilterError, - match="Unrecognized type <> for ipv4 filter ", + # Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15 + match=r"Unrecognized type <> for ipv4 filter ", ): _ipv4(*args) diff --git a/tests/unit/plugins/filter/test_ipv6.py b/tests/unit/plugins/filter/test_ipv6.py index ad18bec2..e0884788 100644 --- a/tests/unit/plugins/filter/test_ipv6.py +++ b/tests/unit/plugins/filter/test_ipv6.py @@ -53,7 +53,8 @@ def test_ipv6_undefined_value(self): args = ["", AnsibleUndefined(name="my_ip"), ""] with pytest.raises( AnsibleFilterError, - match="Unrecognized type <> for ipv6 filter ", + # Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15 + match=r"Unrecognized type <> for ipv6 filter ", ): _ipv6(*args) diff --git a/tests/unit/plugins/filter/test_ipwrap.py b/tests/unit/plugins/filter/test_ipwrap.py index 8694fdb1..a0c0aa47 100644 --- a/tests/unit/plugins/filter/test_ipwrap.py +++ b/tests/unit/plugins/filter/test_ipwrap.py @@ -55,7 +55,8 @@ def test_ipwrap_undefined_value(self): args = ["", AnsibleUndefined(name="my_ip"), ""] with pytest.raises( AnsibleFilterError, - match="Unrecognized type <> for ipwrap filter ", + # Note: this class has been moved to native_helpers dir since 2.16, hence adding regex to be backwards compatable with 2.15 + match=r"Unrecognized type <> for ipwrap filter ", ): _ipwrap(*args)