File: hellotest.py

package info (click to toggle)
pybindgen 0.20.0%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,932 kB
  • sloc: python: 15,981; cpp: 1,889; ansic: 617; makefile: 86; sh: 4
file content (54 lines) | stat: -rw-r--r-- 1,211 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys
import gc
import os.path
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                '..', '..', 'build', 'default', 'tests', 'c-hello'))
import hello
import unittest


class TestHello(unittest.TestCase):

    def test_func(self):
        x = hello.sum(1, 2)
        self.assertEqual(x, 3)

    def test_foo(self):
        foo = hello.Foo()
        data = foo.get_data()
        self.assertEqual(data, None)
        del foo
        while gc.collect():
            pass

    def test_foo2(self):
        foo = hello.Foo("123")
        data = foo.get_data()
        self.assertEqual(data, "123")
        del foo
        while gc.collect():
            pass

    def test_foo3(self):
        foo = hello.Foo(3)
        data = foo.get_data()
        self.assertEqual(data, "   ")
        del foo
        while gc.collect():
            pass

    def test_null_ok(self):
        foo = hello.Foo(3)

        h1 = hello.get_hash(foo)
        self.assertNotEqual(h1, -1)

        h2 = hello.get_hash(None)
        self.assertEqual(h2, -1)

        h3 = hello.get_hash()
        self.assertEqual(h3, -1)
        

if __name__ == '__main__':
    unittest.main()