]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
test: Fix some lint issues after #3298 3396/head
authorBen Darnell <ben@bendarnell.com>
Mon, 10 Jun 2024 16:22:54 +0000 (12:22 -0400)
committerBen Darnell <ben@bendarnell.com>
Mon, 10 Jun 2024 16:22:54 +0000 (12:22 -0400)
That PR arrived while our CI was broken and I
manually verified that the tests passed but didn't
run the linters. These changes are running in to
https://github.com/python/mypy/issues/5088

tornado/test/httpclient_test.py
tornado/test/web_test.py

index 793dce13c5a5bdffac4a39ef436d092263aaacaa..1eb758b5551581e5dd392cd491802c41c92bad6f 100644 (file)
@@ -691,11 +691,13 @@ X-XSS-Protection: 1;
         response = self.fetch("/hello")
         response.rethrow()
         self.assertIsNotNone(response.request_time)
+        assert response.request_time is not None  # for mypy
         self.assertGreaterEqual(response.request_time, 0)
         self.assertLess(response.request_time, 1.0)
         # A very crude check to make sure that start_time is based on
         # wall time and not the monotonic clock.
         self.assertIsNotNone(response.start_time)
+        assert response.start_time is not None  # for mypy
         self.assertLess(abs(response.start_time - start_time), 1.0)
 
         for k, v in response.time_info.items():
index 2fa146d130f15060964b1ba8351af85a985a433e..ecd72635668fa61a78a773bbca99ad21d846c78e 100644 (file)
@@ -132,6 +132,7 @@ class SecureCookieV1Test(unittest.TestCase):
         cookie = handler._cookies["foo"]
         match = re.match(rb"12345678\|([0-9]+)\|([0-9a-f]+)", cookie)
         self.assertIsNotNone(match)
+        assert match is not None  # for mypy
         timestamp = match.group(1)
         sig = match.group(2)
         self.assertEqual(
@@ -402,8 +403,10 @@ class CookieTest(WebTestCase):
         response = self.fetch("/set_expires_days")
         header = response.headers.get("Set-Cookie")
         self.assertIsNotNone(header)
+        assert header is not None  # for mypy
         match = re.match("foo=bar; expires=(?P<expires>.+); Path=/", header)
         self.assertIsNotNone(match)
+        assert match is not None  # for mypy
 
         expires = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
             days=10