Пример #1
0
def a_test_function():
    pass


class foo:
    def __init__(self):

        self.a = False
        self.b = True
        self.c = None
        self.f = a_test_function
        self.k = a_test_class


# always show the family tag so I can make sure it's right
setVerbose(1)
setParanoia(0)

f = foo()

# dump an object containing bools
s = xmp.dumps(f)
print s

x = xmp.loads(s)
print "Expect False, True, None, func, class: ", x.a, x.b, x.c, x.f, x.k

# dump builtin obj containing bools
s = xmp.dumps((True, False))
print s
Пример #2
0
def a_test_function():
    pass


class foo:
    def __init__(self):

        self.a = False
        self.b = True
        self.c = None
        self.f = a_test_function
        self.k = a_test_class


# always show the family tag so I can make sure it's right
setVerbose(1)
setParanoia(0)

f = foo()

# dump an object containing bools
s = xmp.dumps(f)
if SHOW_XML:
    print s

x = xmp.loads(s)
# print "Expect False, True, None, func, class: ",x.a,x.b,x.c,x.f,x.k

# check it
for attr in ["a", "b", "c", "f", "k"]:
    if getattr(f, attr) != getattr(x, attr):