Пример #1
0
    def test_object_references(self):
        x = pyamf.BaseContext()

        self.assertRaises(pyamf.ReferenceError, x.getObject, 62)

        x.exceptions = False
        self.assertEquals(x.getObject(62), None)

        x = pyamf.BaseContext()

        self.assertRaises(pyamf.ReferenceError, x.getObjectReference, object())

        x.exceptions = False
        self.assertEquals(x.getObjectReference(object()), None)
Пример #2
0
    def test_no_alias(self):
        x = pyamf.BaseContext()

        self.assertEquals(x.class_aliases, {})

        class A:
            pass

        self.assertEquals(x.getClassAlias(A), None)
Пример #3
0
    def test_registered_alias(self):
        x = pyamf.BaseContext()

        self.assertEquals(x.class_aliases, {})

        class A:
            pass

        pyamf.register_class(A)
        alias = x.getClassAlias(A)

        self.assertTrue(isinstance(alias, pyamf.ClassAlias))
        self.assertEquals(alias.__class__, pyamf.ClassAlias)
        self.assertEquals(alias.klass, A)
Пример #4
0
    def test_registered_deep(self):
        x = pyamf.BaseContext()

        self.assertEquals(x.class_aliases, {})

        class A:
            pass

        class B(A):
            pass

        pyamf.register_alias_type(DummyAlias, A)
        alias = x.getClassAlias(B)

        self.assertTrue(isinstance(alias, pyamf.ClassAlias))
        self.assertEquals(alias.__class__, DummyAlias)
        self.assertEquals(alias.klass, B)
Пример #5
0
    def test_create(self):
        x = pyamf.BaseContext()

        self.assertTrue(x.exceptions)
        self.assertFalse(x.objects.exceptions)