mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-07 08:54:01 -07:00
[PR #7348/6c9713b3 backport][stable-7] Fix Python 3.12 unit tests (#7351)
Fix Python 3.12 unit tests (#7348)
* Re-enable Python 3.12 unit tests.
* Stop using deprecated alias.
* Stop using long deprecated subset comparison function.
* Avoid another alias.
* Fix name, add Python 2 compatibility.
* Properly make backwards compatible.
(cherry picked from commit 6c9713b36c
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
551e5e4bd5
commit
3cb9b0fa91
9 changed files with 55 additions and 41 deletions
|
@ -6,11 +6,20 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
|
||||
from ansible_collections.community.general.tests.unit.compat import unittest
|
||||
from ansible_collections.community.general.plugins.module_utils.hwc_utils import (HwcModuleException, navigate_value)
|
||||
|
||||
|
||||
class HwcUtilsTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super(HwcUtilsTestCase, self).setUp()
|
||||
|
||||
# Add backward compatibility
|
||||
if sys.version_info < (3, 0):
|
||||
self.assertRaisesRegex = self.assertRaisesRegexp
|
||||
|
||||
def test_navigate_value(self):
|
||||
value = {
|
||||
'foo': {
|
||||
|
@ -29,12 +38,12 @@ class HwcUtilsTestCase(unittest.TestCase):
|
|||
{"foo.quiet.trees": 1}),
|
||||
1)
|
||||
|
||||
self.assertRaisesRegexp(HwcModuleException,
|
||||
r".* key\(q\) is not exist in dict",
|
||||
navigate_value, value, ["foo", "q", "tree"])
|
||||
self.assertRaisesRegex(HwcModuleException,
|
||||
r".* key\(q\) is not exist in dict",
|
||||
navigate_value, value, ["foo", "q", "tree"])
|
||||
|
||||
self.assertRaisesRegexp(HwcModuleException,
|
||||
r".* the index is out of list",
|
||||
navigate_value, value,
|
||||
["foo", "quiet", "trees"],
|
||||
{"foo.quiet.trees": 2})
|
||||
self.assertRaisesRegex(HwcModuleException,
|
||||
r".* the index is out of list",
|
||||
navigate_value, value,
|
||||
["foo", "quiet", "trees"],
|
||||
{"foo.quiet.trees": 2})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue