mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-07-02 18:45:52 +02:00
Fixing flake8 issues
This commit is contained in:
parent
a49fc7af44
commit
e246960c43
|
@ -106,7 +106,7 @@ class TestGetDefaults(Base):
|
|||
"readmedata": {},
|
||||
"readmedatafilename": ("foo" + self.sep +
|
||||
"readmeData.json"),
|
||||
"exclusionpattern": "([a-zA-Z\d-]+\.){0,}",
|
||||
"exclusionpattern": r"([a-zA-Z\d-]+\.){0,}",
|
||||
"exclusionregexs": [],
|
||||
"exclusions": [],
|
||||
"commonexclusions": ["hulu.com"],
|
||||
|
@ -465,8 +465,7 @@ class TestGatherCustomExclusions(BaseStdout):
|
|||
output = sys.stdout.getvalue()
|
||||
self.assertIn(expected, output)
|
||||
|
||||
@mock.patch("updateHostsFile.input", side_effect=["foo", "yes",
|
||||
"bar", "no"])
|
||||
@mock.patch("updateHostsFile.input", side_effect=["foo", "yes", "bar", "no"])
|
||||
@mock.patch("updateHostsFile.is_valid_domain_format", return_value=False)
|
||||
def test_multiple(self, *_):
|
||||
gather_custom_exclusions("foo", [])
|
||||
|
@ -493,7 +492,7 @@ class TestExcludeDomain(Base):
|
|||
exp_count = 0
|
||||
expected_regexes = []
|
||||
exclusion_regexes = []
|
||||
exclusion_pattern = "[a-z]\."
|
||||
exclusion_pattern = r"[a-z]\."
|
||||
|
||||
for domain in ["google.com", "hulu.com", "adaway.org"]:
|
||||
self.assertEqual(len(exclusion_regexes), exp_count)
|
||||
|
@ -519,7 +518,7 @@ class TestMatchesExclusions(Base):
|
|||
self.assertFalse(matches_exclusions(domain, exclusion_regexes))
|
||||
|
||||
def test_no_match_list(self):
|
||||
exclusion_regexes = [".*\.org", ".*\.edu"]
|
||||
exclusion_regexes = [r".*\.org", r".*\.edu"]
|
||||
exclusion_regexes = [re.compile(regex) for regex in exclusion_regexes]
|
||||
|
||||
for domain in ["1.2.3.4 localhost", "5.6.7.8 hulu.com",
|
||||
|
@ -527,7 +526,7 @@ class TestMatchesExclusions(Base):
|
|||
self.assertFalse(matches_exclusions(domain, exclusion_regexes))
|
||||
|
||||
def test_match_list(self):
|
||||
exclusion_regexes = [".*\.com", ".*\.org", ".*\.edu"]
|
||||
exclusion_regexes = [r".*\.com", r".*\.org", r".*\.edu"]
|
||||
exclusion_regexes = [re.compile(regex) for regex in exclusion_regexes]
|
||||
|
||||
for domain in ["5.6.7.8 hulu.com", "9.1.2.3 yahoo.com",
|
||||
|
@ -1089,7 +1088,7 @@ class TestMoveHostsFile(BaseStdout):
|
|||
expected = ("Automatically moving the hosts "
|
||||
"file in place is not yet supported.\n"
|
||||
"Please move the generated file to "
|
||||
"%SystemRoot%\system32\drivers\etc\hosts")
|
||||
r"%SystemRoot%\system32\drivers\etc\hosts")
|
||||
output = sys.stdout.getvalue()
|
||||
self.assertIn(expected, output)
|
||||
|
||||
|
@ -1608,19 +1607,15 @@ class TestQueryYesOrNo(BaseStdout):
|
|||
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@mock.patch("updateHostsFile.input", side_effect=["no", "NO", "N",
|
||||
"n", "No", "nO"])
|
||||
@mock.patch("updateHostsFile.input", side_effect=["no", "NO", "N", "n", "No", "nO"])
|
||||
def test_valid_no(self, _):
|
||||
self.assertFalse(query_yes_no("?", None))
|
||||
|
||||
@mock.patch("updateHostsFile.input", side_effect=["yes", "YES", "Y",
|
||||
"yeS", "y", "YeS",
|
||||
"yES", "YEs"])
|
||||
@mock.patch("updateHostsFile.input", side_effect=["yes", "YES", "Y", "yeS", "y", "YeS", "yES", "YEs"])
|
||||
def test_valid_yes(self, _):
|
||||
self.assertTrue(query_yes_no("?", None))
|
||||
|
||||
@mock.patch("updateHostsFile.input", side_effect=["foo", "yes",
|
||||
"foo", "no"])
|
||||
@mock.patch("updateHostsFile.input", side_effect=["foo", "yes", "foo", "no"])
|
||||
def test_invalid_then_valid(self, _):
|
||||
expected = "Please respond with 'yes' or 'no'"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user