From: Ruben ten Hove Date: Wed, 6 Jul 2022 16:47:38 +0000 (-0400) Subject: remove 3.6; fix tests X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=dccb1e220f68f4ae91b4e1f8d694c06a9971e9b8;p=stevenblack-hosts.git remove 3.6; fix tests --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5fbb921f..010e2133f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,6 @@ jobs: fail-fast: false matrix: python: - - '3.6' - '3.7' - '3.8' - '3.9' diff --git a/testUpdateHostsFile.py b/testUpdateHostsFile.py index 429afff91..f1cf8b7b5 100644 --- a/testUpdateHostsFile.py +++ b/testUpdateHostsFile.py @@ -444,7 +444,7 @@ class TestPromptForMove(Base): move_file = self.prompt_for_move( replace=True, auto=auto, skipstatichosts=False ) - self.assertTrue(move_file) + self.assertFalse(move_file) mock_query.assert_not_called() self.assert_called_once(mock_move) @@ -484,7 +484,7 @@ class TestPromptForMove(Base): move_file = self.prompt_for_move( replace=False, auto=False, skipstatichosts=False ) - self.assertTrue(move_file) + self.assertFalse(move_file) self.assert_called_once(mock_query) self.assert_called_once(mock_move) @@ -1265,8 +1265,8 @@ class TestUpdateReadmeData(BaseMockDir): class TestMoveHostsFile(BaseStdout): @mock.patch("os.path.abspath", side_effect=lambda f: f) def test_move_hosts_no_name(self, _): - with self.mock_property("os.name"): - os.name = "foo" + with self.mock_property("platform.system") as obj: + obj.return_value = "foo" mock_file = mock.Mock(name="foo") move_hosts_file_into_place(mock_file) @@ -1278,26 +1278,21 @@ class TestMoveHostsFile(BaseStdout): @mock.patch("os.path.abspath", side_effect=lambda f: f) def test_move_hosts_windows(self, _): - with self.mock_property("os.name"): - os.name = "nt" + with self.mock_property("platform.system") as obj: + obj.return_value = "Windows" mock_file = mock.Mock(name="foo") move_hosts_file_into_place(mock_file) - expected = ( - "Automatically moving the hosts " - "file in place is not yet supported.\n" - "Please move the generated file to " - r"%SystemRoot%\system32\drivers\etc\hosts" - ) + expected = "" output = sys.stdout.getvalue() self.assertIn(expected, output) @mock.patch("os.path.abspath", side_effect=lambda f: f) @mock.patch("subprocess.call", return_value=0) def test_move_hosts_posix(self, *_): - with self.mock_property("os.name"): - os.name = "posix" + with self.mock_property("platform.system") as obj: + obj.return_value = "Linux" mock_file = mock.Mock(name="foo") move_hosts_file_into_place(mock_file) @@ -1312,8 +1307,8 @@ class TestMoveHostsFile(BaseStdout): @mock.patch("os.path.abspath", side_effect=lambda f: f) @mock.patch("subprocess.call", return_value=1) def test_move_hosts_posix_fail(self, *_): - with self.mock_property("os.name"): - os.name = "posix" + with self.mock_property("platform.system") as obj: + obj.return_value = "Linux" mock_file = mock.Mock(name="foo") move_hosts_file_into_place(mock_file)