@@ 77-102 (lines=26) @@ | ||
74 | assert D().foo == 3 |
|
75 | ||
76 | ||
77 | def test_abstractclassmethod_basics(abc): |
|
78 | @classmethod |
|
79 | @abstractmethod |
|
80 | def foo(cls): |
|
81 | pass |
|
82 | assert foo.__isabstractmethod__ |
|
83 | ||
84 | @classmethod |
|
85 | def bar(cls): |
|
86 | pass |
|
87 | assert not getattr(bar, "__isabstractmethod__", False) |
|
88 | ||
89 | class C(metaclass=type(abc.NamespaceableABC)): |
|
90 | @classmethod |
|
91 | @abstractmethod |
|
92 | def foo(cls): |
|
93 | return cls.__name__ |
|
94 | with pytest.raises(TypeError): |
|
95 | print(C()) |
|
96 | ||
97 | class D(C): |
|
98 | @classmethod |
|
99 | def foo(cls): |
|
100 | return super().foo() |
|
101 | assert D.foo() == 'D' |
|
102 | assert D().foo() == 'D' |
|
103 | ||
104 | ||
105 | def test_abstractstaticmethod_basics(abc): |
|
@@ 51-74 (lines=24) @@ | ||
48 | assert not hasattr(bar, "__isabstractmethod__") |
|
49 | ||
50 | ||
51 | def test_abstractproperty_basics(abc): |
|
52 | @property |
|
53 | @abstractmethod |
|
54 | def foo(self): |
|
55 | pass |
|
56 | assert foo.__isabstractmethod__ |
|
57 | ||
58 | def bar(self): |
|
59 | pass |
|
60 | assert not getattr(bar, "__isabstractmethod__", False) |
|
61 | ||
62 | class C(metaclass=type(abc.NamespaceableABC)): |
|
63 | @property |
|
64 | @abstractmethod |
|
65 | def foo(self): |
|
66 | return 3 |
|
67 | with pytest.raises(TypeError): |
|
68 | print(C()) |
|
69 | ||
70 | class D(C): |
|
71 | @C.foo.getter |
|
72 | def foo(self): |
|
73 | return super().foo |
|
74 | assert D().foo == 3 |
|
75 | ||
76 | ||
77 | def test_abstractclassmethod_basics(abc): |