Test a refused connection's reason, an indented comment and a value between letters
This commit is contained in:
@@ -43,7 +43,7 @@ class ReadEnv(unittest.TestCase):
|
||||
self.assertTrue(isinstance(failed, Failure) and failed.reason.startswith(f"cannot read {self.path}: "), failed)
|
||||
|
||||
def test_parses_quotes_comments_and_spaces(self):
|
||||
self.assertEqual(parse_env("# note\nA = 1 \nB=\"two words\"\nC='3'\nnot a pair\n#D=4\nE=a=b\nF=\"\"\nG='\n"), {"A": "1", "B": "two words", "C": "3", "E": "a=b", "F": "", "G": "'"})
|
||||
self.assertEqual(parse_env("# note\nA = 1 \nB=\"two words\"\nC='3'\nnot a pair\n#D=4\nE=a=b\nF=\"\"\nG='\n # H=5\nI=XaX\n"), {"A": "1", "B": "two words", "C": "3", "E": "a=b", "F": "", "G": "'", "I": "XaX"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -109,9 +109,14 @@ class HttpJson(unittest.TestCase):
|
||||
self.server.server_close()
|
||||
failed = send("GET", f"{base}/api/v4/users/me", "t", None)
|
||||
self.assertIsInstance(failed, Failure)
|
||||
reason = str(getattr(failed, "reason", ""))
|
||||
self.assertTrue(reason.startswith(f"cannot reach {base}: "), failed)
|
||||
self.assertNotIn("urlopen", reason)
|
||||
self.assertTrue(str(getattr(failed, "reason", "")).startswith(f"cannot reach {base}: "), failed)
|
||||
|
||||
def test_names_why_a_server_refuses_the_connection(self):
|
||||
with socket.socket() as taken:
|
||||
taken.bind(("127.0.0.1", 0))
|
||||
port = taken.getsockname()[1]
|
||||
failed = send("GET", f"http://127.0.0.1:{port}/api", "t", None)
|
||||
self.assertEqual(failed, Failure(f"cannot reach http://127.0.0.1:{port}: [Errno 111] Connection refused"))
|
||||
|
||||
def test_an_error_whose_body_is_not_json_names_the_status_alone(self):
|
||||
base = self.serve((403, b"<html>"))
|
||||
|
||||
Reference in New Issue
Block a user