Skip to content

Commit d44bd16

Browse files
committed
Add test case for @Final attribute
1 parent 46ce3e6 commit d44bd16

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mypyc/test-data/run-classes.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,3 +2503,29 @@ class C:
25032503
def test_final_attribute() -> None:
25042504
assert C.A == -1
25052505
assert C.a == [-1]
2506+
2507+
[case testClassWithFinalAttribute]
2508+
from typing import final
2509+
2510+
@final
2511+
class C:
2512+
def a(self) -> int:
2513+
return 1
2514+
2515+
def test_class_final_attribute() -> None:
2516+
assert C().a() == 1
2517+
2518+
[case testClassWithFinalAttributeInherited]
2519+
from typing import final
2520+
2521+
class B:
2522+
def a(self) -> int:
2523+
return 2
2524+
2525+
@final
2526+
class C(B):
2527+
def a(self) -> int:
2528+
return 1
2529+
2530+
def test_class_final_attribute_inherited() -> None:
2531+
assert C().a() == 1

0 commit comments

Comments
 (0)