/
test_minimal.py
62 lines (48 loc) · 1.5 KB
/
test_minimal.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
61
62
import pytest
"""
Currently the pytests are very very limited, and very very generic
(but they exists ;-)
All others reals/tests should be run manually with a real browser, in a real env ;-(
"""
import htbulma as b
from htag import Tag
def test_version():
assert b.__version__
print("HTBulma %s" % b.__version__)
def test_service_reroot_after_clear():
app=Tag.div()
app.service = b.Service(app)
assert app.service in app.childs
app.clear()
assert app.service not in app.childs
app.service._reroot()
assert app.service in app.childs
def test_constructor():
""" the most obvious thing to (badly) test htbulm's objects
it tries to instanciate them, with 0, 1 or 2 parameters
"""
assert b.ALL
parent = Tag.div()
p=[] # list for non zero parameter
for i in b.ALL:
if "service" in str(i):
instance=i(parent)
print("SERVICE:",i,repr(instance))
else:
try:
instance=i()
print("(WITHOUT PARAM):",i,repr(instance))
except TypeError as e:
p.append(i)
pp=[] # list for no zero or one parameter
for i in p:
try:
instance=i("row")
print("(WITH 1 PARAM):",i,repr(instance))
except TypeError as e:
pp.append(i)
for i in pp:
instance=i(".",".")
print("(WITH 2 PARAMS):",i,repr(instance))
# if it works -> all objects can be instanciated with 0, 1 or 2 params
#test_constructor()