]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add test checking value of a TypedDict's __total__ attribute when there is an assignm...
authorDaraan <github.blurry@9ox.net>
Sat, 22 Feb 2025 17:34:22 +0000 (18:34 +0100)
committerGitHub <noreply@github.com>
Sat, 22 Feb 2025 17:34:22 +0000 (09:34 -0800)
In relation to #109544 which changed this behavior.

Signed-off-by: Daniel Sperber <github.blurry@9ox.net>
Lib/test/test_typing.py

index f002d28df60e9c49f9becd918cc5a808d311f04f..591fb860eee1e05ab1f14d460e009d1dd65b4e64 100644 (file)
@@ -8479,6 +8479,22 @@ class TypedDictTests(BaseTestCase):
 
         self.assertIs(TD2.__total__, True)
 
+    def test_total_with_assigned_value(self):
+        class TD(TypedDict):
+            __total__ = "some_value"
+
+        self.assertIs(TD.__total__, True)
+
+        class TD2(TypedDict, total=True):
+            __total__ = "some_value"
+
+        self.assertIs(TD2.__total__, True)
+
+        class TD3(TypedDict, total=False):
+            __total__ = "some value"
+
+        self.assertIs(TD3.__total__, False)
+
     def test_optional_keys(self):
         class Point2Dor3D(Point2D, total=False):
             z: int