]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-108303: Remove `Lib/test/shadowed_super.py` (GH-114372) (#114433)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 22 Jan 2024 15:40:42 +0000 (16:40 +0100)
committerGitHub <noreply@github.com>
Mon, 22 Jan 2024 15:40:42 +0000 (16:40 +0100)
gh-108303: Remove `Lib/test/shadowed_super.py` (GH-114372)

Move code into Lib/test/test_super.py.
(cherry picked from commit 2ef520ebecf5544ba792266a5dbe4d53653a4a03)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/shadowed_super.py [deleted file]
Lib/test/test_super.py

diff --git a/Lib/test/shadowed_super.py b/Lib/test/shadowed_super.py
deleted file mode 100644 (file)
index 2a62f66..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class super:
-    msg = "truly super"
-
-
-class C:
-    def method(self):
-        return super().msg
index 43162c540b55aef8870cf8aa1b4929ea9e9045c3..3ea01413c8e9007928d58fc2ecddd8f0fec67dce 100644 (file)
@@ -1,8 +1,9 @@
 """Unit tests for zero-argument super() & related machinery."""
 
+import textwrap
 import unittest
 from unittest.mock import patch
-from test import shadowed_super
+from test.support import import_helper
 
 
 ADAPTIVE_WARMUP_DELAY = 2
@@ -342,7 +343,20 @@ class TestSuper(unittest.TestCase):
             super(1, int)
 
     def test_shadowed_global(self):
+        source = textwrap.dedent(
+            """
+            class super:
+                msg = "truly super"
+
+            class C:
+                def method(self):
+                    return super().msg
+            """,
+        )
+        with import_helper.ready_to_import(name="shadowed_super", source=source):
+            import shadowed_super
         self.assertEqual(shadowed_super.C().method(), "truly super")
+        import_helper.unload("shadowed_super")
 
     def test_shadowed_local(self):
         class super: