1 # I need to turn this into a proper unit test.
2 # uhm, this is horrible. sorry everybody.
6 from dicthelpers import fallbackdict
11 poop = fallbackdict(fallback)
12 print 'expect 1 (fallback): ' + poop[1]
14 print 'expect 2 (dynamic fallback): ' + poop[2]
16 print 'expect 3 (overridden): ' + poop[2]
18 print 'expect 2 (fallback after delete): ' + poop[2]
20 fallback[3] = '3{three}'
21 print 'expect 33 (formatting): ' + poop[3]
22 print 'expect 4 (len): ' + str(len(poop))
23 fallback['infinite'] = '{infinite}'
24 print 'simple infinite recursion test: ' + poop['infinite']
25 fallback['infone'] = '{inftwo}'
26 fallback['inftwo'] = '{infone}'
27 print 'double infinite recursion test: ' + poop['infone']
28 fallback['2infone'] = '{2inftwo}'
29 fallback['2inftwo'] = '{2infone}'
30 print 'double infinite recursion test: ' + poop['2inftwo']
33 print 'expect 34 (self as string mapping): {three}{four}'.format(**poop)
34 print 'expect 44 (self formatting): ' + poop[4]
35 # silent iter length processing.
36 # this used to take 1 or 2 seconds prior to optimizations
37 for x in poop: poop[x]
40 print "execution " + str(stop - start)