MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/492210_dal2py/recipe-492210.py:99–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97################################################################################
98
99def test():
100 from os import remove, urandom
101 from random import randint
102 test = DAL2(1024, 1024)
103 memo = [None for temp in range(1024)]
104 for temp in range(1024):
105 status = randint(1, 255)
106 block = test.open(status)
107 data = urandom(1024)
108 test.write(block, data)
109 memo[block] = status, data
110 for temp in range(1024):
111 block = randint(0, 1023)
112 if test.status(block):
113 test.close(block)
114 memo[block] = None
115 test.dump('temp')
116 other = DAL2(1, 1)
117 other.load('temp', False)
118 remove('temp')
119 try:
120 for index, information in enumerate(memo):
121 if information is None:
122 assert other.status(index) == 0
123 else:
124 assert other.status(index) == information[0]
125 assert other.read(index) == information[1]
126 valid = False
127 try:
128 other.status(1024)
129 except:
130 valid = True
131 assert valid
132 raw_input('Tested To True')
133 except:
134 raw_input('Tested To False')
135
136################################################################################
137

Callers 1

recipe-492210.pyFile · 0.70

Calls 11

openMethod · 0.95
writeMethod · 0.95
statusMethod · 0.95
closeMethod · 0.95
dumpMethod · 0.95
loadMethod · 0.95
readMethod · 0.95
removeFunction · 0.90
rangeFunction · 0.85
DAL2Class · 0.70
enumerateFunction · 0.50

Tested by

no test coverage detected