2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-21 05:02:17 +00:00
Files
python/pyste/tests/virtualUT.py
Bruno da Silva de Oliveira 7ea2ab1672 - If you export a derived class without exporting its base classes, the derived class will explicitly export the bases's methods and attributes. Before, if you were interested in the bases's methods, you had to export the base classes too.
- Added a new function, no_override. When a member function is specified as "no_override", no virtual wrappers are generated for it, improving performance and letting the code more clean.

- There was a bug in which the policy of virtual member functions was being ignored (patch by Roman Sulzhyk).


[SVN r18814]
2003-06-17 01:34:26 +00:00

52 lines
1.2 KiB
Python

import unittest
from _virtual import *
class VirtualTest(unittest.TestCase):
def testIt(self):
class E(C):
def f_abs(self):
return 3
def dummy(self):
# override should not work
return 100
class F(C):
def f(self):
return 10
def name(self):
return 'F'
class G(D):
def dummy(self):
# override should not work
return 100
e = E()
f = F()
self.assertEqual(e.f(), 3)
self.assertEqual(call_f(e), 3)
self.assertEqual(f.f(), 10)
self.assertEqual(call_f(f), 10)
self.assertEqual(e.get_name(), 'C')
#self.assertEqual(e.get_name(), 'E') check this later
c = C()
c.bar(1) # ok
c.bar('a') # ok
self.assertRaises(TypeError, c.bar, 1.0)
# test no_overrides
d = G()
self.assertEqual(e.dummy(), 100)
self.assertEqual(call_dummy(e), 0)
self.assertEqual(d.dummy(), 100)
self.assertEqual(call_dummy(d), 0)
if __name__ == '__main__':
unittest.main()