mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
[3.13] Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (GH-130460) (#130462)
Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (GH-130460)
In relation to GH-109544 which changed this behavior.
(cherry picked from commit d8ce092fe4
)
Signed-off-by: Daniel Sperber <github.blurry@9ox.net>
Co-authored-by: Daraan <github.blurry@9ox.net>
This commit is contained in:
parent
c68a8722be
commit
6abec03aef
1 changed files with 16 additions and 0 deletions
|
@ -8356,6 +8356,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue