]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/polymorphism.py
1 # Copyright David Abrahams 2004. Distributed under the Boost
2 # Software License, Version 1.0. (See accompanying
3 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 from polymorphism_ext
import *
7 class PolymorphTest(unittest
.TestCase
):
9 def testReturnCpp(self
):
11 # Python Created Object With Same Id As
12 # Cpp Created B Object
15 # Get Reference To Cpp Created B Object
18 # Python Created B Object and Cpp B Object
19 # Should have same result by calling f()
20 self
.assertEqual ('B::f()', a
.f())
21 self
.assertEqual ('B::f()', call_f(a
))
22 self
.assertEqual ('A::f()', call_f(A()))
24 def test_references(self
):
25 # B is not exposed to Python
27 self
.assertEqual(type(a
), A
)
29 # C is exposed to Python
31 self
.assertEqual(type(c
), C
)
33 def test_factory(self
):
34 self
.assertEqual(type(factory(0)), A
)
35 self
.assertEqual(type(factory(1)), A
)
36 self
.assertEqual(type(factory(2)), C
)
38 def test_return_py(self
):
46 self
.assertEqual ('X.f', x
.f())
47 self
.assertEqual ('X.f', call_f(x
))
49 def test_wrapper_downcast(self
):
51 self
.assertEqual('D::g()', a
.g())
53 def test_pure_virtual(self
):
55 self
.assertRaises(RuntimeError, p
.f
)
58 self
.assertEqual ('Q::f()', q
.f())
65 self
.assertEqual ('R.f', r
.f())
68 if __name__
== "__main__":
70 # remove the option which upsets unittest
72 sys
.argv
= [ x
for x
in sys
.argv
if x
!= '--broken-auto-ptr' ]