Exemplo n.º 1
0
    def setUpClass(cls):
        if hasattr(PyjavaTestCase, '_pyjava_started'):
            return

        import _pyjava
        from pyjava.find_dll import find_dll

        dll = find_dll()
        if not dll:
            sys.stderr.write(
                "No suitable JVM DLL found. Please set your JAVA_HOME "
                "environment variable.\n")
            sys.exit(1)
        else:
            sys.stderr.write("Running tests with JVM DLL: %s\n" % dll)

        # This need to be called once, before running the test suite
        _pyjava.start(dll, ['-Djava.class.path=tests/java-tests.jar'])

        PyjavaTestCase._pyjava_started = True
Exemplo n.º 2
0
    def setUpClass(cls):
        if hasattr(PyjavaTestCase, '_pyjava_started'):
            return

        import _pyjava
        from pyjava.find_dll import find_dll


        dll = find_dll()
        if not dll:
            sys.stderr.write("No suitable JVM DLL found. Please set your JAVA_HOME "
                             "environment variable.\n")
            sys.exit(1)
        else:
            sys.stderr.write("Running tests with JVM DLL: %s\n" % dll)


        # This need to be called once, before running the test suite
        _pyjava.start(dll, ['-Djava.class.path=tests/java-tests.jar'])

        PyjavaTestCase._pyjava_started = True
Exemplo n.º 3
0
    def setUpClass(cls):
        if hasattr(PyjavaTestCase, '_pyjava_started'):
            return

        import _pyjava
        from pyjava.find_dll import find_dll


        dll = find_dll()
        if not dll:
            sys.stderr.write("No suitable JVM DLL found. Please set your JAVA_HOME "
                             "environment variable.\n")
            sys.exit(1)
        else:
            sys.stderr.write("Running tests with JVM DLL: %s\n" % dll)


        # This need to be called once, before running the test suite
        class_path = os.path.join(test_java, "classes")  # <AK> added
        _pyjava.start(dll, ["-Djava.class.path={}".format(class_path)])

        PyjavaTestCase._pyjava_started = True
Exemplo n.º 4
0
def start(path, *args):
    try:
        if len(args) == 0:
            _pyjava.start(path, [])
        elif len(args) == 1 and (isinstance(args[0], list)):
            _pyjava.start(path, args[0])
        else:
            _pyjava.start(path, args)
    except Error:
        raise Error("Unable to start Java VM with path %s" % path)
Exemplo n.º 5
0
def start(path=None, *args):
    if path is None:
        from pyjava.find_dll import find_dll
        path = find_dll()
    try:
        if len(args) == 0:
            _pyjava.start(path, [])
        elif len(args) == 1 and (isinstance(args[0], list)):
            _pyjava.start(path, args[0])
        else:
            _pyjava.start(path, args)
    except Error:
        raise Error("Unable to start Java VM with path %s" % path)
Exemplo n.º 6
0
import _pyjava
from tests.find_dll import find_dll


dll = find_dll()
if not dll:
    sys.stderr.write("No suitable JVM DLL found. Please set your JAVA_HOME "
                     "environment variable.\n")
    sys.exit(1)
else:
    sys.stderr.write("Using JVM DLL: %s\n" % dll)


# This need to be called once, before running the test suite
_pyjava.start(dll, ['-Djava.class.path=tests/java-tests.jar'])


class Program(unittest.TestProgram):
    def createTests(self):
        # Is there really no way to load the tests from the package, using
        # TestLoader#discover(), while still using main()?
        # Why would you provide TestLoader, TestRunner and all that nonsense if
        # I can't do that without overriding part of main itself?
        if self.testNames is None:
            self.test = self.testLoader.discover(
                    start_dir=start_dir,
                    pattern='test_*.py',
                    top_level_dir=top_level)
        else:
            self.test = self.testLoader.loadTestsFromNames(self.testNames)