Debian Codegraph @

test/jpypetest/test_closed.py

raw symbols SCIP
1 # *****************************************************************************
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # See NOTICE file for details.
16 #
17 # *****************************************************************************
18 import jpype
19 import common
20
21
22 class ClosedTestCase(common.JPypeTestCase):
23 def setUp(self):
24 common.JPypeTestCase.setUp(self)
25
26 def testObjects(self):
27 from jpype import java
28
29 s = java.lang.String('foo')
30 s._allowed = 1
31 try:
32 s.forbidden = 1
33 except AttributeError:
34 pass
35 else:
36 raise AssertionError("AttributeError not raised")
37
38 def testArrays(self):
39 s = jpype.JArray(jpype.JInt)(5)
40 # Setting private members is allowed
41 s._allowed = 1
42 try:
43 # Setting public members is prohibited
44 s.forbidden = 1
45 except AttributeError:
46 pass
47 else:
48 raise AssertionError("AttributeError not raised")
49
50 def testStatic(self):
51 static = jpype.JClass('jpype.objectwrapper.StaticTest')
52 self.assertEqual(static.i, 1)
53 self.assertEqual(static.d, 1.2345)
54 self.assertEqual(static.s, "hello")