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
|
import test_appliance
from yaml import *
class AnInstance:
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
def __repr__(self):
try:
return "%s(foo=%r, bar=%r)" % (self.__class__.__name__,
self.foo, self.bar)
except RuntimeError:
return "%s(foo=..., bar=...)" % self.__class__.__name__
class AnInstanceWithState(AnInstance):
def __getstate__(self):
return {'attributes': [self.foo, self.bar]}
def __setstate__(self, state):
self.foo, self.bar = state['attributes']
class TestRecursive(test_appliance.TestAppliance):
def _testRecursive(self, test_name, recursive_filename):
exec file(recursive_filename, 'r').read()
value1 = value
output1 = None
value2 = None
output2 = None
try:
output1 = dump(value1)
#print "OUTPUT %s:" % test_name
#print output1
value2 = load(output1)
output2 = dump(value2)
self.failUnlessEqual(output1, output2)
except:
print "VALUE1:", value1
print "VALUE2:", value2
print "OUTPUT1:"
print output1
print "OUTPUT2:"
print output2
raise
TestRecursive.add_tests('testRecursive', '.recursive')
|