Skip to content

Commit

Permalink
Tests private cache for dataclass forward-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Oct 9, 2022
1 parent 2f63e27 commit 533541d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,27 @@ class Tree:
t = Tree('a', [t])
self.assertRaises(TypeError, Tree, 'a', [1])

def test_forward_reference_cache(self):
@dataclass
class A:
b: 'B'

class B:
pass

a = A(B())
self.assertRaises(TypeError, A, 1)

@dataclass
class A:
b: 'B'

class B:
pass

a = A(B())
self.assertRaises(TypeError, A, 1)

def test_unfrozen(self):
@dataclass(frozen=False, slots=False)
class A:
Expand Down

0 comments on commit 533541d

Please sign in to comment.