1 | # Copyright Bruno da Silva de Oliveira 2003. Use, modification and |
---|
2 | # distribution is subject to the Boost Software License, Version 1.0. |
---|
3 | # (See accompanying file LICENSE_1_0.txt or copy at |
---|
4 | # http:#www.boost.org/LICENSE_1_0.txt) |
---|
5 | import sys |
---|
6 | from Pyste.infos import * |
---|
7 | from Pyste.policies import * |
---|
8 | from Pyste.exporterutils import * |
---|
9 | import unittest |
---|
10 | |
---|
11 | #================================================================================ |
---|
12 | # InfosTest |
---|
13 | #================================================================================ |
---|
14 | class InfosTest(unittest.TestCase): |
---|
15 | |
---|
16 | def testFunctionInfo(self): |
---|
17 | info = FunctionInfo('test::foo', 'foo.h') |
---|
18 | rename(info, 'hello') |
---|
19 | set_policy(info, return_internal_reference()) |
---|
20 | set_wrapper(info, FunctionWrapper('foo_wrapper')) |
---|
21 | |
---|
22 | info = InfoWrapper(info) |
---|
23 | |
---|
24 | self.assertEqual(info.rename, 'hello') |
---|
25 | self.assertEqual(info.policy.Code(), 'return_internal_reference< 1 >') |
---|
26 | self.assertEqual(info.wrapper.name, 'foo_wrapper') |
---|
27 | |
---|
28 | |
---|
29 | def testClassInfo(self): |
---|
30 | info = ClassInfo('test::IFoo', 'foo.h') |
---|
31 | rename(info.name, 'Name') |
---|
32 | rename(info.exclude, 'Exclude') |
---|
33 | rename(info, 'Foo') |
---|
34 | rename(info.Bar, 'bar') |
---|
35 | set_policy(info.Baz, return_internal_reference()) |
---|
36 | rename(info.operator['>>'], 'from_string') |
---|
37 | exclude(info.Bar) |
---|
38 | set_wrapper(info.Baz, FunctionWrapper('baz_wrapper')) |
---|
39 | |
---|
40 | info = InfoWrapper(info) |
---|
41 | |
---|
42 | self.assertEqual(info.rename, 'Foo') |
---|
43 | self.assertEqual(info['Bar'].rename, 'bar') |
---|
44 | self.assertEqual(info['name'].rename, 'Name') |
---|
45 | self.assertEqual(info['exclude'].rename, 'Exclude') |
---|
46 | self.assertEqual(info['Bar'].exclude, True) |
---|
47 | self.assertEqual(info['Baz'].policy.Code(), 'return_internal_reference< 1 >') |
---|
48 | self.assertEqual(info['Baz'].wrapper.name, 'baz_wrapper') |
---|
49 | self.assertEqual(info['operator']['>>'].rename, 'from_string') |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | if __name__ == '__main__': |
---|
55 | unittest.main() |
---|