Esempio n. 1
0
    def constructData(self):
        root = SObject()
        root.aString = "other thing"
        root.anotherStr = "bananas"
        root.anInt = 12
        root.none = None
        root.aBool = False
        root.big_str = _BIG_STR

        root.s2 = SObject(
            ('some_float', 200.0), ('someBool', True),
            ('unicode_test',
             u'some unicode value "with crap in it"\nand a newline!'))
        root.s2.crazy_list = [
            1, 2.5, '3', True, False,
            [
                'nested', 'lists', 'are', 'fun',
                (7, 8, 9, {
                    'dict': 1,
                    'inside': 2,
                    'tuple': (3)
                })
            ]
        ]
        root.s2.emptyTuple = ()
        root.s2.similarKeyDict = {123: 'key as int', '123': 'key as str'}

        root.s3 = SObject(('duplicate_ref_to_s2', root.s2), (
            'a_stupidly_long_attribute_name_to_test_whether_it_works_ok_with_serialization',
            0x902))

        root.s4 = SObject(('recursive_ref_to_root', root),
                          ('anotherTokenAttribute', -100))

        #test SObjects in lists - mixed with other stuff
        root.s5 = SObject()
        root.s5.objList = [
            root.s2, root.s3, root.s5, 1, 3.5, True, False, None
        ]
        root.s5.largeList = range(1000)

        #test tuples
        root.s6 = SObject(('aTuple', (1, 2, 3)),
                          ('objTuple', (SObject(), SObject())))

        assert root.s4.recursive_ref_to_root is root

        return root
Esempio n. 2
0
    def constructData(self):
        root = SObject()
        root.aString = "other thing"
        root.anotherStr = "bananas"
        root.anInt = 12
        root.none = None
        root.aBool = False
        root.big_str = _BIG_STR

        root.s2 = SObject(
            ("some_float", 200.0),
            ("someBool", True),
            ("unicode_test", u'some unicode value "with crap in it"\nand a newline!'),
        )
        root.s2.crazy_list = [
            1,
            2.5,
            "3",
            True,
            False,
            ["nested", "lists", "are", "fun", (7, 8, 9, {"dict": 1, "inside": 2, "tuple": (3)})],
        ]
        root.s2.emptyTuple = ()
        root.s2.similarKeyDict = {123: "key as int", "123": "key as str"}

        root.s3 = SObject(
            ("duplicate_ref_to_s2", root.s2),
            ("a_stupidly_long_attribute_name_to_test_whether_it_works_ok_with_serialization", 0x902),
        )

        root.s4 = SObject(("recursive_ref_to_root", root), ("anotherTokenAttribute", -100))

        # test SObjects in lists - mixed with other stuff
        root.s5 = SObject()
        root.s5.objList = [root.s2, root.s3, root.s5, 1, 3.5, True, False, None]
        root.s5.largeList = range(1000)

        # test tuples
        root.s6 = SObject(("aTuple", (1, 2, 3)), ("objTuple", (SObject(), SObject())))

        assert root.s4.recursive_ref_to_root is root

        return root