GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.12] Improve test coverage for is_typeddict (GH-104884) (#104889) · python/cpython@3d91d03

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/test
    • test_typing.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_typing.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_typing.py
+22-3Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7223,10 +7223,29 @@ class Wrong(*bases):
72237223
pass
72247224

72257225
def test_is_typeddict(self):
7226-
assert is_typeddict(Point2D) is True
7227-
assert is_typeddict(Union[str, int]) is False
7226+
self.assertIs(is_typeddict(Point2D), True)
7227+
self.assertIs(is_typeddict(Union[str, int]), False)
72287228
# classes, not instances
7229-
assert is_typeddict(Point2D()) is False
7229+
self.assertIs(is_typeddict(Point2D()), False)
7230+
call_based = TypedDict('call_based', {'a': int})
7231+
self.assertIs(is_typeddict(call_based), True)
7232+
self.assertIs(is_typeddict(call_based()), False)
7233+
7234+
T = TypeVar("T")
7235+
class BarGeneric(TypedDict, Generic[T]):
7236+
a: T
7237+
self.assertIs(is_typeddict(BarGeneric), True)
7238+
self.assertIs(is_typeddict(BarGeneric[int]), False)
7239+
self.assertIs(is_typeddict(BarGeneric()), False)
7240+
7241+
class NewGeneric[T](TypedDict):
7242+
a: T
7243+
self.assertIs(is_typeddict(NewGeneric), True)
7244+
self.assertIs(is_typeddict(NewGeneric[int]), False)
7245+
self.assertIs(is_typeddict(NewGeneric()), False)
7246+
7247+
# The TypedDict constructor is not itself a TypedDict
7248+
self.assertIs(is_typeddict(TypedDict), False)
72307249

72317250
def test_get_type_hints(self):
72327251
self.assertEqual(

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.