diff options
author | Matt Clay <mclay@redhat.com> | 2022-01-07 21:31:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 21:31:11 +0100 |
commit | 97104f1221b64ef36cf42cb90c5a0eff263a2adb (patch) | |
tree | 390b2a53ff77e8430b98f15ecdf85bb4f9e35cff /test/units/module_utils/facts/test_collector.py | |
parent | Make all pipelining agree on ini entries (#76573) (diff) | |
download | ansible-97104f1221b64ef36cf42cb90c5a0eff263a2adb.tar.xz ansible-97104f1221b64ef36cf42cb90c5a0eff263a2adb.zip |
Avoid deprecated TestCase functions in unit tests. (#76678)
* Avoid deprecated TestCase functions in unit tests.
* Add assertRaisesRegex for Python 2.7.
* Fix indentation.
Diffstat (limited to 'test/units/module_utils/facts/test_collector.py')
-rw-r--r-- | test/units/module_utils/facts/test_collector.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/test/units/module_utils/facts/test_collector.py b/test/units/module_utils/facts/test_collector.py index 9eab89f7aa..4fc4bc5f72 100644 --- a/test/units/module_utils/facts/test_collector.py +++ b/test/units/module_utils/facts/test_collector.py @@ -265,12 +265,12 @@ class TestGetCollectorNames(unittest.TestCase): valid_subsets = frozenset(['my_fact', 'something_else']) minimal_gather_subset = frozenset(['my_fact']) - self.assertRaisesRegexp(TypeError, - r'Bad subset .* given to Ansible.*allowed\:.*all,.*my_fact.*', - collector.get_collector_names, - valid_subsets=valid_subsets, - minimal_gather_subset=minimal_gather_subset, - gather_subset=['my_fact', 'not_a_valid_gather_subset']) + self.assertRaisesRegex(TypeError, + r'Bad subset .* given to Ansible.*allowed\:.*all,.*my_fact.*', + collector.get_collector_names, + valid_subsets=valid_subsets, + minimal_gather_subset=minimal_gather_subset, + gather_subset=['my_fact', 'not_a_valid_gather_subset']) class TestFindUnresolvedRequires(unittest.TestCase): @@ -349,10 +349,10 @@ class TestResolveRequires(unittest.TestCase): all_fact_subsets = {'env': [default_collectors.EnvFactCollector], 'network': [default_collectors.LinuxNetworkCollector], 'virtual': [default_collectors.LinuxVirtualCollector]} - self.assertRaisesRegexp(collector.UnresolvedFactDep, - 'unresolved fact dep.*required_thing2', - collector.resolve_requires, - unresolved, all_fact_subsets) + self.assertRaisesRegex(collector.UnresolvedFactDep, + 'unresolved fact dep.*required_thing2', + collector.resolve_requires, + unresolved, all_fact_subsets) def test(self): unresolved = ['env', 'network'] @@ -556,8 +556,8 @@ class TestCollectorClassesFromGatherSubset(unittest.TestCase): def test_unknown_collector(self): # something claims 'unknown_collector' is a valid gather_subset, but there is # no FactCollector mapped to 'unknown_collector' - self.assertRaisesRegexp(TypeError, - r'Bad subset.*unknown_collector.*given to Ansible.*allowed\:.*all,.*env.*', - self._classes, - all_collector_classes=default_collectors.collectors, - gather_subset=['env', 'unknown_collector']) + self.assertRaisesRegex(TypeError, + r'Bad subset.*unknown_collector.*given to Ansible.*allowed\:.*all,.*env.*', + self._classes, + all_collector_classes=default_collectors.collectors, + gather_subset=['env', 'unknown_collector']) |