From: Ben Darnell Date: Mon, 10 Jun 2024 16:22:54 +0000 (-0400) Subject: test: Fix some lint issues after #3298 X-Git-Tag: v6.5.0b1~55^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2f419fd5b8920bb3edcfd2a0dc26f5ec7a4adf9;p=thirdparty%2Ftornado.git test: Fix some lint issues after #3298 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 --- diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 793dce13..1eb758b5 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -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(): diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 2fa146d1..ecd72635 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -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.+); Path=/", header) self.assertIsNotNone(match) + assert match is not None # for mypy expires = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( days=10