Skip to content
Permalink
Browse files

setup.py test works

  • Loading branch information...
Thrameos committed May 22, 2019
1 parent d72ddec commit 6072ee557abd786ddad5fb9c8b92baae7f555059
@@ -5,4 +5,3 @@ include *.rst doc/* LICENSE
graft test
graft setupext
global-exclude *.pyc
prune test/classes

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1,6 @@
[alias]
test=pytest

[tool:pytest]
addopts = --verbose
python_files = test/jpypetest/test_*.py
@@ -35,18 +35,19 @@
'Programming Language :: Python :: 3.6',
],
packages=[
'jpype', 'jpypex', 'jpypex.swing'],
'jpype'],
package_dir={
'jpype': 'jpype',
'jpypex': 'jpypex',
},
tests_requires=['pytest'],
extras_require={'numpy': ['numpy>=1.6']},
cmdclass={
'build_java': setupext.build_java.BuildJavaCommand,
'build_thunk': setupext.build_thunk.BuildThunkCommand,
'build_ext': setupext.build_ext.BuildExtCommand,
'test_java': setupext.test_java.TestJavaCommand,
'sdist': setupext.sdist.BuildSourceDistribution,
'test': setupext.pytester.PyTest,
},
zip_safe=False,
ext_modules=[jpypeLib],
@@ -6,3 +6,4 @@
from . import build_thunk
from . import test_java
from . import sdist
from . import pytester
@@ -0,0 +1,24 @@
import sys

from setuptools.command.test import test as TestCommand


class PyTest(TestCommand):
user_options = [("pytest-args=", "a", "Arguments to pass to pytest")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ""

def run_tests(self):
self.run_command("test_java")

import shlex

# import here, cause outside the eggs aren't loaded
import pytest

errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)


@@ -17,6 +17,7 @@ class BuildSourceDistribution(sdist):
def run(self):
# We need to build a jar cache for the source distribution
self.run_command("build_java")
self.run_command("test_java")
dest = os.path.join('native','jars')
src = os.path.join('build','lib')
if not os.path.exists(src):
@@ -21,6 +21,10 @@ def finalize_options(self):

def run(self):
"""Run command."""
if os.path.exists(os.path.join("test", "classes")):
distutils.log.info("Skip building Java testbench")
return
distutils.log.info("Building Java testbench")
buildXmlFile = os.path.join("test", "build.xml")
command = [self.distribution.ant, '-f', buildXmlFile]
cmdStr = ' '.join(command)
@@ -56,13 +56,13 @@ def testForceOverloadResolution(self):
self.assertEqual('B', test1.testMostSpecific(
JObject(self._c, self._bclass)))
# JObject wrapper forces exact matches
#self.assertRaisesRegexp(RuntimeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, self._cclass))
#self.assertRaisesRegex(RuntimeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, self._cclass))
self.assertEqual('A', test1.testMostSpecific(
JObject(self._c, 'jpype.overloads.Test1$A')))
self.assertEqual('B', test1.testMostSpecific(
JObject(self._c, 'jpype.overloads.Test1$B')))
# JObject wrapper forces exact matches
#self.assertRaisesRegexp(RuntimeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, 'jpype.overloads.Test1$C'))
#self.assertRaisesRegex(RuntimeError, 'No matching overloads found', test1.testMostSpecific, JObject(self._c, 'jpype.overloads.Test1$C'))

def testVarArgsCall(self):
test1 = self.__jp.Test1()
@@ -117,7 +117,7 @@ def testInstanceVsClassMethod(self):

def testInterfaces1(self):
test1 = self.__jp.Test1()
self.assertRaisesRegexp(
self.assertRaisesRegex(
RuntimeError, 'Ambiguous overloads found', test1.testInterfaces1, self._i4impl)
self.assertEqual('I2', test1.testInterfaces1(
JObject(self._i4impl, 'jpype.overloads.Test1$I2')))
@@ -134,10 +134,10 @@ def testInterfaces2(self):

def testInterfaces3(self):
test1 = self.__jp.Test1()
self.assertRaisesRegexp(
self.assertRaisesRegex(
RuntimeError, 'Ambiguous overloads found', test1.testInterfaces3, self._i8impl)
self.assertEqual('I4', test1.testInterfaces3(self._i6impl))
self.assertRaisesRegexp(
self.assertRaisesRegex(
RuntimeError, 'No matching overloads found', test1.testInterfaces3, self._i3impl)

def testInterfaces4(self):
@@ -166,7 +166,7 @@ def testStringArray(self):
test1 = self.__jp.Test1()
self.assertEqual('Object', test1.testStringArray(self._i4impl))
self.assertEqual('Object', test1.testStringArray(1))
self.assertRaisesRegexp(
self.assertRaisesRegex(
RuntimeError, 'Ambiguous overloads found', test1.testStringArray, None)
self.assertEqual('String', test1.testStringArray('somestring'))
self.assertEqual('String[]', test1.testStringArray([]))

0 comments on commit 6072ee5

Please sign in to comment.
You can’t perform that action at this time.