From 1ba100a3b4749ba76603aee744fe40493dce593d Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 7 Feb 2023 14:00:38 -0800 Subject: [PATCH] Fix pointless statements in unit tests (#79940) --- test/units/inventory/test_host.py | 8 ++++---- test/units/module_utils/facts/test_timeout.py | 2 +- test/units/plugins/action/test_pause.py | 2 +- test/units/plugins/cache/test_cache.py | 2 +- test/units/utils/test_unsafe_proxy.py | 12 ++++++------ test/units/vars/test_variable_manager.py | 6 ++---- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/test/units/inventory/test_host.py b/test/units/inventory/test_host.py index c8f477145e6..712ed302b7a 100644 --- a/test/units/inventory/test_host.py +++ b/test/units/inventory/test_host.py @@ -69,10 +69,10 @@ class TestHost(unittest.TestCase): def test_equals_none(self): other = None - self.hostA == other - other == self.hostA - self.hostA != other - other != self.hostA + assert not (self.hostA == other) + assert not (other == self.hostA) + assert self.hostA != other + assert other != self.hostA self.assertNotEqual(self.hostA, other) def test_serialize(self): diff --git a/test/units/module_utils/facts/test_timeout.py b/test/units/module_utils/facts/test_timeout.py index 2adbc4a6f3f..6ba7c397d5c 100644 --- a/test/units/module_utils/facts/test_timeout.py +++ b/test/units/module_utils/facts/test_timeout.py @@ -139,7 +139,7 @@ def function_other_timeout(): @timeout.timeout(1) def function_raises(): - 1 / 0 + return 1 / 0 @timeout.timeout(1) diff --git a/test/units/plugins/action/test_pause.py b/test/units/plugins/action/test_pause.py index fc4325f46d6..cbd9a17d213 100644 --- a/test/units/plugins/action/test_pause.py +++ b/test/units/plugins/action/test_pause.py @@ -58,7 +58,7 @@ def test_pause_missing_curses(mocker, monkeypatch): mod = importlib.import_module('ansible.plugins.action.pause') with pytest.raises(AttributeError): - mod.curses + mod.curses # pylint: disable=pointless-statement assert mod.HAS_CURSES is False assert mod.MOVE_TO_BOL == b'\r' diff --git a/test/units/plugins/cache/test_cache.py b/test/units/plugins/cache/test_cache.py index 31a1da7014a..b4ffe4e3799 100644 --- a/test/units/plugins/cache/test_cache.py +++ b/test/units/plugins/cache/test_cache.py @@ -66,7 +66,7 @@ class TestCachePluginAdjudicator(unittest.TestCase): def test___getitem__(self): with pytest.raises(KeyError): - self.cache['foo'] + self.cache['foo'] # pylint: disable=pointless-statement def test_pop_with_default(self): assert self.cache.pop('foo', 'bar') == 'bar' diff --git a/test/units/utils/test_unsafe_proxy.py b/test/units/utils/test_unsafe_proxy.py index 3c40a7a3214..fbb0bcdc5fa 100644 --- a/test/units/utils/test_unsafe_proxy.py +++ b/test/units/utils/test_unsafe_proxy.py @@ -91,12 +91,12 @@ def test_wrap_var_no_ref(): 'text': 'text', } wrapped_thing = wrap_var(thing) - thing is not wrapped_thing - thing['foo'] is not wrapped_thing['foo'] - thing['bar'][0] is not wrapped_thing['bar'][0] - thing['baz'][0] is not wrapped_thing['baz'][0] - thing['none'] is not wrapped_thing['none'] - thing['text'] is not wrapped_thing['text'] + assert thing is not wrapped_thing + assert thing['foo'] is not wrapped_thing['foo'] + assert thing['bar'][0] is not wrapped_thing['bar'][0] + assert thing['baz'][0] is not wrapped_thing['baz'][0] + assert thing['none'] is wrapped_thing['none'] + assert thing['text'] is not wrapped_thing['text'] def test_AnsibleUnsafeText(): diff --git a/test/units/vars/test_variable_manager.py b/test/units/vars/test_variable_manager.py index 67ec120b1da..ee6de817b16 100644 --- a/test/units/vars/test_variable_manager.py +++ b/test/units/vars/test_variable_manager.py @@ -141,10 +141,8 @@ class TestVariableManager(unittest.TestCase): return # pylint: disable=unreachable - ''' - Tests complex variations and combinations of get_vars() with different - objects to modify the context under which variables are merged. - ''' + # Tests complex variations and combinations of get_vars() with different + # objects to modify the context under which variables are merged. # FIXME: BCS makethiswork # return True