コード例 #1
0
def test_all(test):
    try:
        serialized = pyxser.serialize(obj=test,
                                      enc="utf-8",
                                      typemap=test_typemap_map,
                                      selector=sel)
        pyxser.validate(obj=serialized, enc="utf-8")
        pyxser.validate_dtd(obj=serialized, enc="utf-8")
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")

        serialized = pyxser.serialize_c14n(obj=test, depth=0, com=0)
        pyxser.validate_c14n(obj=serialized, enc="utf-8")
        pyxser.validate_c14n_dtd(obj=serialized, enc="utf-8")

        serialized = pyxser.u_serialize(obj=test,
                                        enc="utf-8",
                                        typemap=test_typemap_map,
                                        selector=sel)
        pyxser.u_validate(obj=serialized, enc="utf-8")
        pyxser.u_validate_dtd(obj=serialized, enc="utf-8")
        unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8")

        serialized = pyxser.u_serialize_c14n(obj=test, depth=0, com=0)
        pyxser.u_validate_c14n(obj=serialized, enc="utf-8")
        pyxser.u_validate_c14n_dtd(obj=serialized, enc="utf-8")

        pyxser.getdtd()
        pyxser.getdtd_c14n()
        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #2
0
ファイル: test-utf8-leak-cinit.py プロジェクト: dmw/pyxser
def test_normal(test):
    try:
        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #3
0
ファイル: test-utf8-leak.py プロジェクト: kaymccormick/pyxser
def test_normal(test):
    try:
        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #4
0
def test_all(test):
    try:
        serialized = pyxser.serialize(obj = test, enc = "utf-8", typemap = test_typemap_map, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize_c14n(obj = test, depth = 0, com = 0)
        pyxser.validate_c14n(obj = serialized, enc = "utf-8")
        pyxser.validate_c14n_dtd(obj = serialized, enc = "utf-8")

        serialized = pyxser.u_serialize(obj = test, enc = "utf-8", typemap = test_typemap_map, selector = sel)
        pyxser.u_validate(obj = serialized, enc = "utf-8")
        pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.u_serialize_c14n(obj = test, depth = 0, com = 0)
        pyxser.u_validate_c14n(obj = serialized, enc = "utf-8")
        pyxser.u_validate_c14n_dtd(obj = serialized, enc = "utf-8")

        pyxser.getdtd()
        pyxser.getdtd_c14n()
        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #5
0
ファイル: test-utf16.py プロジェクト: dmw/pyxser
def test_selector(test):
    try:
        print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()"
        print "First Object:\n" + repr(test) + "\n\n"

        x = sel(test)
        print repr(x)

        serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 2, selector = sel)
        print "Serilized Object:\n", serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16")
        print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 3, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16")
        print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 4, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16")
        print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 5, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16")
        print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 0, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16", cinit = False)
        print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #6
0
ファイル: test-utf8.py プロジェクト: kaymccormick/pyxser
def test_normal(test):
    try:
        print(
            "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()"
        )
        print("First Object:\n" + repr(test) + "\n\n")

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=100)
        print("Serilized Object:%s\n" % (serialized))
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=3)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=4)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=5)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=0)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized,
                                          enc="utf-8",
                                          cinit=False)
        print("Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n")

        pyxser.xmlcleanup()

    except Exception:
        print("-" * 60)
        traceback.print_exc(file=sys.stdout)
        print("-" * 60)
コード例 #7
0
def test_selector(test):
    try:
        print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()"
        print "First Object:\n" + repr(test) + "\n\n"

        x = sel(test)
        print repr(x)

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2, selector = sel)
        print "Serilized Object:\n", serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii")
        print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 3, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii")
        print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 4, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii")
        print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 5, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii")
        print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 0, selector = sel)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii")
        print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #8
0
ファイル: test-utf8.py プロジェクト: dmw/pyxser
def test_selector(test):
    try:
        print("-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()")
        print("First Object:\n" + repr(test) + "\n\n")

        x = sel(test)
        print(repr(x))

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, selector = sel)
        print("Serilized Object:\n", serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, selector = sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, selector = sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, selector = sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = {}, cinit = False)
        print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, selector = sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n")

        pyxser.xmlcleanup()

    except Exception:
        print("-" * 60)
        traceback.print_exc(file=sys.stdout)
        print("-" * 60)
コード例 #9
0
ファイル: test-utf16.py プロジェクト: kaymccormick/pyxser
def test_normal(test):
    try:
        print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()"
        print "First Object:\n" + repr(test) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-16", depth=2)
        print "Serilized Object:\n", serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-16")
        print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-16", depth=3)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-16")
        print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-16", depth=4)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-16")
        print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-16", depth=5)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-16")
        print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-16", depth=0)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-16"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-16")
        unserialized = pyxser.unserialize(obj=serialized,
                                          enc="utf-16",
                                          cinit=False)
        print "Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #10
0
ファイル: test-utf8.py プロジェクト: dmw/pyxser
def test_normal(test):
    try:
        print("-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()")
        print("First Object:\n" + repr(test) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 100)
        print("Serilized Object:%s\n" % (serialized))
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n")


        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")
        print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8",
                                          cinit = False)
        print("Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n")

        pyxser.xmlcleanup()

    except Exception:
        print("-" * 60)
        traceback.print_exc(file=sys.stdout)
        print("-" * 60)
コード例 #11
0
def test_typemap(test):
    try:
        print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_typemap()"
        print "First Object:\n" + repr(test) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2, typemap = test_typemap_map)
        print "Serilized Object:\n", serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 3, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 4, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 5, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 0, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map,
                                          cinit = False)
        print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #12
0
ファイル: test-ascii.py プロジェクト: dmw/pyxser
def test_typemap(test):
    try:
        print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_typemap()"
        print "First Object:\n" + repr(test) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2, typemap = test_typemap_map)
        print "Serilized Object:\n", serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 3, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 4, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 5, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map)
        print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 0, typemap = test_typemap_map)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "ascii"), \
              pyxser.validate_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map,
                                          cinit = False)
        print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #13
0
ファイル: test-utf8.py プロジェクト: krichter722/pyxser
def test_normal(test):
    try:
        print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()"
        print "First Object:\n" + repr(test) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=2)
        print "Serilized Object:\n", serialized
        print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd(
            obj=serialized, enc="utf-8"
        )
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=3)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd(
            obj=serialized, enc="utf-8"
        )
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=4)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd(
            obj=serialized, enc="utf-8"
        )
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=5)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd(
            obj=serialized, enc="utf-8"
        )
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n"

        serialized = pyxser.serialize(obj=test, enc="utf-8", depth=0)
        print "Serilized Object:\n" + serialized
        print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd(
            obj=serialized, enc="utf-8"
        )
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", cinit=False)
        print "Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #14
0
ファイル: test-utf8-leak-cinit.py プロジェクト: dmw/pyxser
def test_selector(test):
    try:
        x = sel(test)
        print repr(x)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False)

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #15
0
ファイル: test-utf8-leak.py プロジェクト: kaymccormick/pyxser
def test_selector(test):
    try:
        x = sel(test)
        print repr(x)

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, selector = sel)
        pyxser.validate(obj = serialized, enc = "utf-8")
        pyxser.validate_dtd(obj = serialized, enc = "utf-8")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        print e
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
コード例 #16
0
ファイル: test-errors.py プロジェクト: dmw/pyxser
    test.dyn_prop2 = (u'hol`', u'sïn', 'trip', other)
    test.dyn_prop3 = {'saludo1': u'hólà', 'saludo2': u'chäó', 'saludo4': 'goodbye', 'saludo5': thisc}
    test.dyn_prop4 = u'sómé tèxtè ïñ Unicodè'
    test.dyn_prop5 = u'Añother Texé Iñ ÜnìcóDËc'
    test.dyn_prop6 = 1.5
    test.dyn_prop7 = 1000

    try:
        serialized = pyxser.serialize(obj = None, enc = None, depth = "hola")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        pyxser.validate("wawawawaw", enc = "utf-8")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        unserialized = pyxser.unserialize(obj = "wawawawaw", enc = "utf-8")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        print "-" * 60
        serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2)
コード例 #17
0
        'saludo5': thisc
    }
    test.dyn_prop4 = u'sómé tèxtè ïñ Unicodè'
    test.dyn_prop5 = u'Añother Texé Iñ ÜnìcóDËc'
    test.dyn_prop6 = 1.5
    test.dyn_prop7 = 1000

    try:
        serialized = pyxser.serialize(obj=None, enc=None, depth="hola")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        pyxser.validate("wawawawaw", enc="utf-8")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        unserialized = pyxser.unserialize(obj="wawawawaw", enc="utf-8")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        print "-" * 60
        serialized = pyxser.serialize(obj=test, enc="ascii", depth=2)
コード例 #18
0
ファイル: test-utf8.py プロジェクト: kaymccormick/pyxser
def test_selector(test):
    try:
        print(
            "-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()"
        )
        print("First Object:\n" + repr(test) + "\n\n")

        x = sel(test)
        print(repr(x))

        serialized = pyxser.serialize(obj=test,
                                      enc="utf-8",
                                      depth=2,
                                      selector=sel)
        print("Serilized Object:\n", serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test,
                                      enc="utf-8",
                                      depth=3,
                                      selector=sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test,
                                      enc="utf-8",
                                      depth=4,
                                      selector=sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test,
                                      enc="utf-8",
                                      depth=5,
                                      selector=sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized,
                                          enc="utf-8",
                                          typemap={},
                                          cinit=False)
        print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n")

        serialized = pyxser.serialize(obj=test,
                                      enc="utf-8",
                                      depth=0,
                                      selector=sel)
        print("Serilized Object:\n" + serialized)
        print("Serilized Object Validation:\n", \
              pyxser.validate(obj = serialized, enc = "utf-8"), \
              pyxser.validate_dtd(obj = serialized, enc = "utf-8"))
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")
        print("Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n")

        pyxser.xmlcleanup()

    except Exception:
        print("-" * 60)
        traceback.print_exc(file=sys.stdout)
        print("-" * 60)