From: Ben Darnell Date: Tue, 22 Aug 2023 03:14:49 +0000 (-0400) Subject: test: Fix circlerefs test on python 3.10 and before X-Git-Tag: v6.4.0b1~12^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e80e9441b8777b2dbe78de5dd783bb6fcd3d00d5;p=thirdparty%2Ftornado.git test: Fix circlerefs test on python 3.10 and before Local/attribute dicts are reported a bit differently here. --- diff --git a/tornado/test/circlerefs_test.py b/tornado/test/circlerefs_test.py index 3908588c5..49b53f96f 100644 --- a/tornado/test/circlerefs_test.py +++ b/tornado/test/circlerefs_test.py @@ -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(