File: importstar.py

package info (click to toggle)
python-jpype 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,984 kB
  • sloc: python: 18,767; cpp: 17,931; java: 8,448; xml: 1,305; makefile: 154; sh: 35
file content (28 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (2)
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
# This is a short test to see what happens when we import using star.
#
#   Unfortunately this can only be done from a module level so we
#   will need to include a special module for this test.
#
#   When we start the test late2.jar will not be in the current classpath.
#   But we will add it later and make sure the directory updates for us.
import jpype

# import with star the first time
from org.jpype import *  # type: ignore

try:
    # This should not be found
    late2.Test()  # type: ignore[name-defined]
    raise ImportError("late was already found")
except NameError:
    pass

# Path is relative to this module
jpype.addClassPath("../jar/late/late2.jar")

# Second import
if True:
    from org.jpype import *  # type: ignore[name-defined]

# This time it should work
t = late2.Test()  # type: ignore[name-defined]