File: bulletproof.py

package info (click to toggle)
python-jpype 0.6.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,560 kB
  • sloc: cpp: 11,957; python: 3,844; java: 986; ansic: 875; makefile: 149; xml: 76; sh: 62
file content (60 lines) | stat: -rw-r--r-- 2,619 bytes parent folder | download
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
55
56
57
58
59
60
import unittest
import jpype
import _jpype

class TestJpypeModule(unittest.TestCase):
    def setUp(self):
        self.methods={
           'attach': [tuple(["none"]),RuntimeError],
           'attachThreadAsDaemon': [tuple(),RuntimeError],
           'attachThreadToJVM': [tuple(), RuntimeError],
           'convertToDirectBuffer': [tuple(), RuntimeError],
           'convertToJValue': [tuple(["a",1]), RuntimeError],
           'createProxy': [tuple(['a',(1,2)]), AttributeError],
           'detachThreadFromJVM': [tuple(), RuntimeError],
           'dumpJVMStats': [tuple(), None],
           'findArrayClass': [tuple('double[]'), RuntimeError],
           'findClass': [tuple('java.lang.String'), RuntimeError],
           'getArrayItem': [tuple([None,1]), TypeError],
           'getArrayLength': [tuple([None]), TypeError],
           'getArraySlice': [tuple([None,1,2]), TypeError],
           'isStarted': [tuple(), None],
           'isThreadAttachedToJVM': [tuple(), RuntimeError],
           'newArray': [tuple([None,1]), TypeError],
           'setArrayItem': [tuple([None,1,2]), TypeError],
           'setArraySlice': [tuple([None,1,2,3]), TypeError],
           'setConvertStringObjects': [tuple(), RuntimeError],
           'setGetClassMethod': [tuple([None]), None],
           'setGetJavaArrayClassMethod': [tuple([None]), None],
           'setJavaArrayClass': [tuple([None]), None],
           'setJavaExceptionClass': [tuple([None]), None],
           'setJavaLangObjectClass': [tuple([None]), None],
           'setProxyClass': [tuple([None]), None],
           'setSpecialConstructorKey': [tuple([None]), None],
           'setStringWrapperClass': [tuple([None]), None],
           'setWrapperClass': [tuple([None]), None],
           'shutdown': [tuple(), RuntimeError],
           'startReferenceQueue': [tuple([1]), RuntimeError],
           'startup': [tuple([None,tuple([None]),None]), TypeError],
           'stopReferenceQueue': [tuple(), RuntimeError],
           'synchronized': [tuple(), None],
           }

    def testEntryPoints(self):
        for n,c in self.methods.items():
            print('====',n)
            method=getattr(_jpype, n)
            args=c[0]
            expect=c[1]
            if expect==None:
                method(*args)
            else:
                self.assertRaises(expect, method, *args)


# This is a special test suite that checks to see that every entry point to the private
# module will safely fail rather than segfaulting.  It can't be run with other tests
# as the jvm must not be loaded.
#
# To test use
#   nosetests test.bulletproof