-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mod.py
69 lines (58 loc) · 1.92 KB
/
test_mod.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
63
64
65
66
67
68
69
import pytest
from .mod import Modules, BaseModules, SimpleModules
@pytest.fixture()
def basemod():
bm = BaseModules()
bm.nodes
bm.mods
bm.fitness = 5.0
return
# this was mainly copied from test_boxlist. not properly adjusted
class aTestBaseModules:
""" tests for basic properties of a BasicBoxList"""
def test_getitem(self, baseboxlist):
"""should behave like list inside"""
l = baseboxlist.boxes.copy()
n = len(l)
for i in range(n):
assert baseboxlist[i] == l[i]
for i, b in enumerate(baseboxlist):
assert b == l[i]
def test_setitem(self, baseboxlist):
"""should set items into list"""
baseboxlist[0] = 2
print(baseboxlist)
assert baseboxlist[0] == 2
def test_del(self, baseboxlist):
"""should delete item like list"""
l = baseboxlist.boxes.copy()
del baseboxlist[1]
del l[1]
assert baseboxlist[0] == l[0]
assert baseboxlist[1] == l[1]
def test_len(self, baseboxlist):
"""should say len of internal list"""
l = baseboxlist.boxes
assert len(l) == len(baseboxlist)
def test_copy_identical_contents(self, baseboxlist):
"""should say len of internal list"""
box1 = baseboxlist
box2 = baseboxlist.copy()
assert type(box1) == type(box2)
for i, b in enumerate(box1):
assert b == box2[i]
assert box1.fitness == box2.fitness
def test_copy_seperate_pointers(self, baseboxlist):
"""should say len of internal list"""
box1 = baseboxlist
box2 = baseboxlist.copy()
del box1[0]
assert len(box1) == len(box2) - 1
box1.fitness += 1
assert box1.fitness != box2.fitness
# TODO: add in this method
def test_insert(self, baseboxlist):
baseboxlist
# TODO: add in this method
def test_items(self, baseboxlist):
pass