Beispiel #1
0
 def testMethodSelfIdentity(self):
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     im_ = aot.unjellyFromSource(aot.jellyToSource(b)).a.bmethod
     self.assertEquals(im_.im_class, im_.im_self.__class__)
Beispiel #2
0
 def testCopyReg(self):
     s = "foo_bar"
     sio = StringIO.StringIO()
     sio.write(s)
     uj = aot.unjellyFromSource(aot.jellyToSource(sio))
     # print repr(uj.__dict__)
     assert uj.getvalue() == s
Beispiel #3
0
 def test_copyReg(self):
     """
     L{aot.jellyToSource} and L{aot.unjellyFromSource} honor functions
     registered in the pickle copy registry.
     """
     uj = aot.unjellyFromSource(aot.jellyToSource(CopyRegistered()))
     self.assertIsInstance(uj, CopyRegisteredLoaded)
Beispiel #4
0
 def test_basicIdentity(self):
     # Anyone wanting to make this datastructure more complex, and thus this
     # test more comprehensive, is welcome to do so.
     aj = aot.AOTJellier().jellyToAO
     d = {"hello": "world", "method": aj}
     l = [
         1,
         2,
         3,
         'he\tllo\n\n"x world!',
         "goodbye \n\t\u1010 world!",
         1,
         1.0,
         100**100,
         unittest,
         aot.AOTJellier,
         d,
         funktion,
     ]
     t = tuple(l)
     l.append(l)
     l.append(t)
     l.append(t)
     uj = aot.unjellyFromSource(aot.jellyToSource([l, l]))
     assert uj[0] is uj[1]
     assert uj[1][0:5] == l[0:5]
 def test_methodSelfIdentity(self):
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     im_ = aot.unjellyFromSource(aot.jellyToSource(b)).a.bmethod
     self.assertEqual(im_.im_class, im_.im_self.__class__)
 def test_copyReg(self):
     """
     L{aot.jellyToSource} and L{aot.unjellyFromSource} honor functions
     registered in the pickle copy registry.
     """
     uj = aot.unjellyFromSource(aot.jellyToSource(CopyRegistered()))
     self.assertIsInstance(uj, CopyRegisteredLoaded)
 def test_copyReg(self):
     s = "foo_bar"
     sio = StringIO.StringIO()
     sio.write(s)
     uj = aot.unjellyFromSource(aot.jellyToSource(sio))
     # print repr(uj.__dict__)
     assert uj.getvalue() == s
Beispiel #8
0
 def test_methodSelfIdentity(self):
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     im_ = aot.unjellyFromSource(aot.jellyToSource(b)).a.bmethod
     self.assertEqual(aot._selfOfMethod(im_).__class__,
                      aot._classOfMethod(im_))
 def test_methodSelfIdentity(self):
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     im_ = aot.unjellyFromSource(aot.jellyToSource(b)).a.bmethod
     self.assertEqual(aot._selfOfMethod(im_).__class__,
                      aot._classOfMethod(im_))
Beispiel #10
0
 def test_simpleTypes(self):
     obj = (
         1,
         2.0,
         3j,
         True,
         slice(1, 2, 3),
         "hello",
         "world",
         sys.maxsize + 1,
         None,
         Ellipsis,
     )
     rtObj = aot.unjellyFromSource(aot.jellyToSource(obj))
     self.assertEqual(obj, rtObj)
Beispiel #11
0
 def testBasicIdentity(self):
     aj = aot.AOTJellier().jellyToAO
     d = {'hello': 'world', "method": aj}
     l = [1, 2, 3,
          "he\tllo\n\n\"x world!",
          u"goodbye \n\t\u1010 world!",
          1, 1.0, 100 ** 100l, unittest, aot.AOTJellier, d,
          funktion
          ]
     t = tuple(l)
     l.append(l)
     l.append(t)
     l.append(t)
     uj = aot.unjellyFromSource(aot.jellyToSource([l, l]))
     assert uj[0] is uj[1]
     assert uj[1][0:5] == l[0:5]
 def test_methodNotSelfIdentity(self):
     """
     If a class change after an instance has been created,
     L{aot.unjellyFromSource} shoud raise a C{TypeError} when trying to
     unjelly the instance.
     """
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     savedbmethod = B.bmethod
     del B.bmethod
     try:
         self.assertRaises(TypeError, aot.unjellyFromSource,
                           aot.jellyToSource(b))
     finally:
         B.bmethod = savedbmethod
Beispiel #13
0
 def test_methodNotSelfIdentity(self):
     """
     If a class change after an instance has been created,
     L{aot.unjellyFromSource} shoud raise a C{TypeError} when trying to
     unjelly the instance.
     """
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     savedbmethod = B.bmethod
     del B.bmethod
     try:
         self.assertRaises(TypeError, aot.unjellyFromSource,
                           aot.jellyToSource(b))
     finally:
         B.bmethod = savedbmethod
 def test_basicIdentity(self):
     # Anyone wanting to make this datastructure more complex, and thus this
     # test more comprehensive, is welcome to do so.
     aj = aot.AOTJellier().jellyToAO
     d = {'hello': 'world', "method": aj}
     l = [1, 2, 3,
          "he\tllo\n\n\"x world!",
          u"goodbye \n\t\u1010 world!",
          1, 1.0, 100 ** 100l, unittest, aot.AOTJellier, d,
          funktion
          ]
     t = tuple(l)
     l.append(l)
     l.append(t)
     l.append(t)
     uj = aot.unjellyFromSource(aot.jellyToSource([l, l]))
     assert uj[0] is uj[1]
     assert uj[1][0:5] == l[0:5]
Beispiel #15
0
 def test_nonDictState(self):
     a = NonDictState()
     a.state = "meringue!"
     assert aot.unjellyFromSource(aot.jellyToSource(a)).state == a.state
 def test_nonDictState(self):
     a = NonDictState()
     a.state = "meringue!"
     assert aot.unjellyFromSource(aot.jellyToSource(a)).state == a.state
 def test_simpleTypes(self):
     obj = (1, 2.0, 3j, True, slice(1, 2, 3), 'hello', u'world', sys.maxint + 1, None, Ellipsis)
     rtObj = aot.unjellyFromSource(aot.jellyToSource(obj))
     self.assertEqual(obj, rtObj)
Beispiel #18
0
 def testCopyReg(self):
     s = "foo_bar"
     sio = StringIO.StringIO()
     sio.write(s)
     uj = aot.unjellyFromSource(aot.jellyToSource(sio))
     assert uj.getvalue() == s
Beispiel #19
0
 def testSimpleTypes(self):
     obj = (1, 2.0, 3j, True, slice(1, 2, 3), 'hello', u'world',
            sys.maxint + 1, None, Ellipsis)
     rtObj = aot.unjellyFromSource(aot.jellyToSource(obj))
     self.assertEquals(obj, rtObj)