コード例 #1
0
ファイル: test402.py プロジェクト: Britefury/jython
'''

test402m adds a jar file to sys.path and imports a package from it.  The first
run ensures that, by default, package scanning is enabled for jars added to
sys.path.  The second run turns off package scanning, so it checks that the
package is unimportable without the scan.  Finally, we run test402n which adds
the same jar to its sys.path and imports a fully qualified class from it.  We
run it with package scanning off to make sure that even without package
scanning, jars are correctly added to sys.path and fully qualified class
imports work on them.

'''

import support
import jarmaker

jarmaker.mkjar()

support.runJython('test402m.py')
ret = support.runJython('test402m.py', error='test402.err',
        javaargs='-Dpython.cachedir.skip=true', expectError=1)
if ret == 0:
    raise support.TestError('Successfully imported a package from a jar on sys.path without caching!')
support.runJython('test402n.py', javaargs='-Dpython.cachedir.skip=true')
コード例 #2
0
ファイル: test385.py プロジェクト: Anemone95/jython3
"""
Try importing from a jar after sys.path.append(jar)

This nails down a bug reported here:
    http://sourceforge.net/mailarchive/message.php?msg_id=14088259
which only occurred on systems where java.io.File.separatorChar is not a forward slash ('/')
   
since - at the moment - jython modules hide java packages with the same name from import,
use a unique java package name for the sake of this test 
"""

import jarmaker
import support
import sys

jarfn, package, clazz = jarmaker.mkjar()
# append this jar file to sys.path
sys.path.append(jarfn)

# try to import the class
importStmt = "from %s import %s" % (package, clazz)
try:
    exec(importStmt)
finally:
    sys.path.remove(jarfn)
コード例 #3
0
ファイル: test402.py プロジェクト: shyamalschandra/jython-1
'''

test402m adds a jar file to sys.path and imports a package from it.  The first
run ensures that, by default, package scanning is enabled for jars added to
sys.path.  The second run turns off package scanning, so it checks that the
package is unimportable without the scan.  Finally, we run test402n which adds
the same jar to its sys.path and imports a fully qualified class from it.  We
run it with package scanning off to make sure that even without package
scanning, jars are correctly added to sys.path and fully qualified class
imports work on them.

'''

import support
import jarmaker

jarmaker.mkjar()

support.runJython('test402m.py')
ret = support.runJython('test402m.py',
                        error='test402.err',
                        javaargs='-Dpython.cachedir.skip=true',
                        expectError=1)
if ret == 0:
    raise support.TestError(
        'Successfully imported a package from a jar on sys.path without caching!'
    )
support.runJython('test402n.py', javaargs='-Dpython.cachedir.skip=true')