mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-07-01 02:36:52 +00:00
test source existence; actually fix tests
This commit is contained in:
@@ -1264,17 +1264,17 @@ class TestUpdateReadmeData(BaseMockDir):
|
||||
|
||||
class TestMoveHostsFile(BaseStdout):
|
||||
@mock.patch("os.path.abspath", side_effect=lambda f: f)
|
||||
def test_move_hosts_no_name(self, _):
|
||||
def test_move_hosts_no_name(self, _): # TODO: Create test which tries to move actual file
|
||||
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)
|
||||
|
||||
expected = ""
|
||||
expected = "does not exist"
|
||||
output = sys.stdout.getvalue()
|
||||
|
||||
self.assertEqual(output, expected)
|
||||
self.assertIn(expected, output)
|
||||
|
||||
@mock.patch("os.path.abspath", side_effect=lambda f: f)
|
||||
def test_move_hosts_windows(self, _):
|
||||
@@ -1290,17 +1290,14 @@ class TestMoveHostsFile(BaseStdout):
|
||||
|
||||
@mock.patch("os.path.abspath", side_effect=lambda f: f)
|
||||
@mock.patch("subprocess.call", return_value=0)
|
||||
def test_move_hosts_posix(self, *_):
|
||||
def test_move_hosts_posix(self, *_): # TODO: create test which tries to move an actual file
|
||||
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)
|
||||
|
||||
expected = (
|
||||
"Moving the file requires administrative "
|
||||
"privileges. You might need to enter your password."
|
||||
)
|
||||
expected = "does not exist."
|
||||
output = sys.stdout.getvalue()
|
||||
self.assertIn(expected, output)
|
||||
|
||||
@@ -1313,7 +1310,7 @@ class TestMoveHostsFile(BaseStdout):
|
||||
mock_file = mock.Mock(name="foo")
|
||||
move_hosts_file_into_place(mock_file)
|
||||
|
||||
expected = "Moving the file failed."
|
||||
expected = "does not exist."
|
||||
output = sys.stdout.getvalue()
|
||||
self.assertIn(expected, output)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user