From ca936f5e1a3bf8fd1e877964a249a4c941fd1b4c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 15 Dec 2017 16:19:42 +0000 Subject: [PATCH] fixes --- tests/functional/openlp_core/common/test_actions.py | 4 ++-- tests/functional/openlp_core/common/test_httputils.py | 2 +- tests/functional/openlp_core/common/test_init.py | 6 +++--- tests/functional/openlp_core/common/test_json.py | 2 +- tests/functional/openlp_core/common/test_mixins.py | 2 +- tests/functional/openlp_core/common/test_path.py | 6 +++--- .../openlp_core/common/test_projector_utilities.py | 6 +++--- tests/functional/openlp_core/common/test_registry.py | 6 +++--- tests/functional/openlp_core/ui/test_mainwindow.py | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/functional/openlp_core/common/test_actions.py b/tests/functional/openlp_core/common/test_actions.py index d5d1abcf0..7d5ac6fca 100644 --- a/tests/functional/openlp_core/common/test_actions.py +++ b/tests/functional/openlp_core/common/test_actions.py @@ -124,8 +124,8 @@ class TestCategoryActionList(TestCase): local_list = [a for a in self.list] # THEN: Make sure they are returned in correct order assert len(self.list) == 2 - assert local_list[0] == self.action1 - assert local_list[1] == self.action2 + assert local_list[0] is self.action1 + assert local_list[1] is self.action2 def test_remove(self): """ diff --git a/tests/functional/openlp_core/common/test_httputils.py b/tests/functional/openlp_core/common/test_httputils.py index ad1ab6e46..0b39033d9 100644 --- a/tests/functional/openlp_core/common/test_httputils.py +++ b/tests/functional/openlp_core/common/test_httputils.py @@ -240,4 +240,4 @@ class TestHttpUtils(TestCase, TestMixin): # THEN: socket.timeout should have been caught # NOTE: Test is if $tmpdir/tempfile is still there, then test fails since ftw deletes bad downloaded files - assert not os.path.exists(self.tempfile), 'tempfile should have been deleted' + assert os.path.exists(self.tempfile) is False, 'tempfile should have been deleted' diff --git a/tests/functional/openlp_core/common/test_init.py b/tests/functional/openlp_core/common/test_init.py index fbeaec957..5292f414e 100644 --- a/tests/functional/openlp_core/common/test_init.py +++ b/tests/functional/openlp_core/common/test_init.py @@ -258,7 +258,7 @@ class TestInit(TestCase, TestMixin): result = delete_file(None) # THEN: delete_file should return False - assert not result, "delete_file should return False when called with None" + assert result is False, "delete_file should return False when called with None" def test_delete_file_path_success(self): """ @@ -271,7 +271,7 @@ class TestInit(TestCase, TestMixin): result = delete_file(Path('path', 'file.ext')) # THEN: delete_file should return True - assert result, 'delete_file should return True when it successfully deletes a file' + assert result is True, 'delete_file should return True when it successfully deletes a file' def test_delete_file_path_no_file_exists(self): """ @@ -363,4 +363,4 @@ class TestInit(TestCase, TestMixin): # THEN: log.exception should be called and get_file_encoding should return None mocked_log.exception.assert_called_once_with('Error detecting file encoding') - assert not result + assert result is None diff --git a/tests/functional/openlp_core/common/test_json.py b/tests/functional/openlp_core/common/test_json.py index 392b30c9b..18cba3b4e 100644 --- a/tests/functional/openlp_core/common/test_json.py +++ b/tests/functional/openlp_core/common/test_json.py @@ -60,7 +60,7 @@ class TestOpenLPJsonDecoder(TestCase): # THEN: The object should be returned unchanged and a Path object should not have been initiated assert result == {'key': 'value'} - assert not mocked_path.called + assert mocked_path.called is False def test_json_decode(self): """ diff --git a/tests/functional/openlp_core/common/test_mixins.py b/tests/functional/openlp_core/common/test_mixins.py index db9606d4e..f49c2b797 100644 --- a/tests/functional/openlp_core/common/test_mixins.py +++ b/tests/functional/openlp_core/common/test_mixins.py @@ -46,7 +46,7 @@ class TestRegistryProperties(TestCase, RegistryProperties): # GIVEN an Empty Registry # WHEN there is no Application # THEN the application should be none - assert not self.application, 'The application value should be None' + assert self.application is None, 'The application value should be None' def test_application(self): """ diff --git a/tests/functional/openlp_core/common/test_path.py b/tests/functional/openlp_core/common/test_path.py index 42d78cc7e..b069c251d 100644 --- a/tests/functional/openlp_core/common/test_path.py +++ b/tests/functional/openlp_core/common/test_path.py @@ -213,7 +213,7 @@ class TestShutil(TestCase): # THEN: :func:`shutil.which` should have been called with the command, and :func:`which` should return None. mocked_shutil_which.assert_called_once_with('no_command') - assert not result + assert result is None def test_which_command(self): """ @@ -256,7 +256,7 @@ class TestPath(TestCase): result = path_to_str(None) # THEN: `path_to_str` should return an empty string - assert not result + assert result == '' def test_path_to_str_path_object(self): """ @@ -288,7 +288,7 @@ class TestPath(TestCase): result = str_to_path('') # THEN: `path_to_str` should return None - assert not result + assert result is None def test_path_encode_json(self): """ diff --git a/tests/functional/openlp_core/common/test_projector_utilities.py b/tests/functional/openlp_core/common/test_projector_utilities.py index 45e13c04d..db163c152 100644 --- a/tests/functional/openlp_core/common/test_projector_utilities.py +++ b/tests/functional/openlp_core/common/test_projector_utilities.py @@ -45,7 +45,7 @@ ip6_link_local = 'fe80::223:14ff:fe99:d315' ip6_bad = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' -class testProjectorUtilities(TestCase): +class TestProjectorUtilities(TestCase): """ Validate functions in the projector utilities module """ @@ -87,7 +87,7 @@ class testProjectorUtilities(TestCase): valid = verify_ip_address(addr=ip4_bad) # THEN: Verify we received True - assert not valid, 'Bad IPv4 address should not have been valid' + assert valid is False, 'Bad IPv4 address should not have been valid' def test_ip6_loopback_valid(self): """ @@ -117,7 +117,7 @@ class testProjectorUtilities(TestCase): valid = verify_ip_address(addr=ip6_bad) # THEN: Validate bad return - assert not valid, 'IPv6 bad address should have been invalid' + assert valid is False, 'IPv6 bad address should have been invalid' def test_md5_hash(self): """ diff --git a/tests/functional/openlp_core/common/test_registry.py b/tests/functional/openlp_core/common/test_registry.py index 81b4230a1..7e8a80e14 100644 --- a/tests/functional/openlp_core/common/test_registry.py +++ b/tests/functional/openlp_core/common/test_registry.py @@ -57,13 +57,13 @@ class TestRegistry(TestCase): # WHEN I try to get back a non existent component # THEN I will get an exception temp = Registry().get('test2') - assert not temp, 'None should have been returned for missing service' + assert temp is False, 'None should have been returned for missing service' # WHEN I try to replace a component I should be allowed Registry().remove('test1') # THEN I will get an exception temp = Registry().get('test1') - assert not temp, 'None should have been returned for deleted service' + assert temp is False, 'None should have been returned for deleted service' def test_registry_function(self): """ @@ -142,7 +142,7 @@ class TestRegistry(TestCase): Registry().remove_function('test1', self.dummy_function_1) # THEN: The method should not be available. - assert not Registry().functions_list['test1'], 'The function should not be in the dict anymore.' + assert Registry().functions_list['test1'] is None, 'The function should not be in the dict anymore.' def dummy_function_1(self): return "function_1" diff --git a/tests/functional/openlp_core/ui/test_mainwindow.py b/tests/functional/openlp_core/ui/test_mainwindow.py index 4a0404eab..9dee80c0d 100644 --- a/tests/functional/openlp_core/ui/test_mainwindow.py +++ b/tests/functional/openlp_core/ui/test_mainwindow.py @@ -106,7 +106,7 @@ class TestMainWindow(TestCase, TestMixin): self.main_window.open_cmd_line_files("") # THEN the file should not be opened - assert not mocked_load_file.called, 'load_file should not have been called' + assert mocked_load_file.called is False, 'load_file should not have been called' def test_main_window_title(self): """