(supressoutput = False)
| 93 | return nodaldict[0].pop() |
| 94 | |
| 95 | def test(supressoutput = False): |
| 96 | testvectors = [ |
| 97 | list(((None, True, False), (1, 12341234123412341234123412341234L,0.5), |
| 98 | 0.12341234123412341234, |
| 99 | u'This is\nan\tUnicode string\u0A0D\N{HANGUL SYLLABLE BYENH}', |
| 100 | set(('A','B','D')), |
| 101 | frozenset(tuple((1, '9', -0.12341234123412341234+1j, 'Y'))))), |
| 102 | tuple(), |
| 103 | list(), |
| 104 | set(), |
| 105 | frozenset(), |
| 106 | 'Element that is not nested.', |
| 107 | {'a': (1, "Waka"), ('X', 'K'): u'CD', u'y':{ 1:'O', 2:('T','wo')}}] |
| 108 | |
| 109 | # Recursion not yet properly supported. |
| 110 | #x = {'a': None, 'z': None} |
| 111 | #y = {'x': x} |
| 112 | #x['y'] = y |
| 113 | #testvectors.extend([x,y]) |
| 114 | for root in testvectors: |
| 115 | serialized = serialize(root) |
| 116 | inverse = deserialize(serialized) |
| 117 | if not supressoutput: |
| 118 | print "Expected: ", repr(root) |
| 119 | print "Returned: ", repr(inverse) |
| 120 | if (inverse != root): |
| 121 | raise ValueError, "The test failed." |
| 122 | |
| 123 | if __name__ == '__main__': |
| 124 | print "Running test..." |
no test coverage detected