/
tests.py
60 lines (39 loc) · 981 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pytest
from pycompose import Compose
class A:
test1 = "123"
def hello(self):
print("A")
def __repr__(self):
return "<A>"
class B:
test2 = "456"
def hello(self):
print("B")
def __repr__(self):
return "<B>"
class C(
Compose(A, "test1", ("hello", "helloA")),
Compose(B, "test2", ("hello", "helloB"), name="b_object"),
):
...
class D:
def __init__(self, test):
self.test = test
class E(Compose(D, "test", "test2", args=("this is a test",))):
...
class F(Compose(D, "test", args=("this is a test",))):
...
def test_basic_function():
c = C()
assert c.test1 + c.test2 == "123456"
assert hasattr(c, "helloA")
assert hasattr(c, "helloB")
assert isinstance(c._a, A)
assert isinstance(c.b_object, B)
with pytest.raises(TypeError):
E()
f = F()
assert f.test == "this is a test"
f.test = "this is a different test"
del f.test