Skip to content

Commit 7f72d4e

Browse files
committed
Refactor test_mozilla_httponly_prefix to use subTest
1 parent 2d1ea7a commit 7f72d4e

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

Lib/test/test_http_cookiejar.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,19 +1958,17 @@ def test_mozilla_httponly_prefix(self):
19581958

19591959
# Check that the HttpOnly prefix is added to the correct cookies
19601960
for key in ["foo1", "foo2", "foo3"]:
1961-
matches = [x for x in lines if key in x]
1962-
self.assertEqual(len(matches), 1,
1963-
"Incorrect number of matches for cookie with value %r" % key)
1964-
self.assertTrue(matches[0].startswith("#HttpOnly_"),
1965-
"Cookie with value %r is missing the HttpOnly prefix" % key)
1961+
with self.subTest(key=key):
1962+
matches = [x for x in lines if key in x]
1963+
self.assertEqual(len(matches), 1)
1964+
self.assertTrue(matches[0].startswith("#HttpOnly_"))
19661965

19671966
# Check that the HttpOnly prefix is not added to the correct cookies
19681967
for key in ["foo4"]:
1969-
matches = [x for x in lines if key in x]
1970-
self.assertEqual(len(matches), 1,
1971-
"Incorrect number of matches for cookie with value %r" % key)
1972-
self.assertFalse(matches[0].startswith("#HttpOnly_"),
1973-
"Cookie with value %r has the HttpOnly prefix" % key)
1968+
with self.subTest(key=key):
1969+
matches = [x for x in lines if key in x]
1970+
self.assertEqual(len(matches), 1)
1971+
self.assertFalse(matches[0].startswith("#HttpOnly_"))
19741972

19751973
def test_netscape_misc(self):
19761974
# Some additional Netscape cookies tests.

0 commit comments

Comments
 (0)