1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
5 Tests for L{twisted.persisted.styles}.
8 from twisted.trial import unittest
9 from twisted.persisted.styles import unpickleMethod
30 class UnpickleMethodTestCase(unittest.TestCase):
32 Tests for the unpickleMethod function.
35 def test_instanceBuildingNamePresent(self):
37 L{unpickleMethod} returns an instance method bound to the
38 instance passed to it.
41 m = unpickleMethod('method', foo, Foo)
42 self.assertEqual(m, foo.method)
43 self.assertNotIdentical(m, foo.method)
46 def test_instanceBuildingNameNotPresent(self):
48 If the named method is not present in the class,
49 L{unpickleMethod} finds a method on the class of the instance
50 and returns a bound method from there.
53 m = unpickleMethod('method', foo, Bar)
54 self.assertEqual(m, foo.method)
55 self.assertNotIdentical(m, foo.method)