]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
test: Fix circlerefs test on python 3.10 and before
authorBen Darnell <ben@bendarnell.com>
Tue, 22 Aug 2023 03:14:49 +0000 (23:14 -0400)
committerBen Darnell <ben@bendarnell.com>
Tue, 22 Aug 2023 03:14:49 +0000 (23:14 -0400)
Local/attribute dicts are reported a bit differently here.

tornado/test/circlerefs_test.py

index 3908588c596032c249143bc918bf9462a6a24011..49b53f96f6f799888c9b9270eb489edcf88f9dd7 100644 (file)
@@ -125,9 +125,14 @@ class CircleRefsTest(unittest.TestCase):
                 b.c = c
                 del a, b
         self.assertIn("Circular", str(cm.exception))
-        self.assertIn("name=a", str(cm.exception))
-        self.assertIn("name=b", str(cm.exception))
-        self.assertNotIn("name=c", str(cm.exception))
+        # Leading spaces ensure we only catch these at the beginning of a line, meaning they are a
+        # cycle participant and not simply the contents of a locals dict or similar container. (This
+        # depends on the formatting above which isn't ideal but this test evolved from a
+        # command-line script) Note that the behavior here changed in python 3.11; in newer pythons
+        # locals are handled a bit differently and the test passes without the spaces.
+        self.assertIn("    name=a", str(cm.exception))
+        self.assertIn("    name=b", str(cm.exception))
+        self.assertNotIn("    name=c", str(cm.exception))
 
     async def run_handler(self, handler_class):
         app = web.Application(