Permalink
Browse files

Start working on python 3 compatability.

  • Loading branch information...
baztian committed Feb 10, 2015
1 parent bb8fce0 commit daff8f5bbd42176f4b9de240c4016a6ad3d1c1c7
Showing with 23 additions and 27 deletions.
  1. +1 −0 test-requirements-py3.txt
  2. +22 −26 test/jpypetest/attr.py
  3. +0 −1 test/testsuite.py
@@ -0,0 +1 @@
mock==1.0.1
@@ -26,7 +26,7 @@ def setUp(self) :
def testWithBufferStrategy(self):
j = jpype.JPackage("jpype").attr.ClassWithBuffer
print j
self.assertIsNone(j().bufferStrategy)
def testCallOverloadedMethodWithCovariance(self):
# This is a JDk5-specific problem.
@@ -38,42 +38,43 @@ def testCallStaticString(self) :
h = self.__jp.Test1()
v = h.testString(JString("abcd"), JString("abcde"))
assert v[0] == 'abcd'
assert v[1] == 'abcde'
self.assertEqual(v[0], 'abcd')
self.assertEqual(v[1], 'abcde')
def testCallStaticUnicodeString(self) :
h = self.__jp.Test1()
v = h.testString(JString(u"abcd"), JString(u"abcde"))
assert v[0] == 'abcd'
assert v[1] == 'abcde'
self.assertEqual(v[0], 'abcd')
self.assertEqual(v[1], 'abcde')
def testCallString(self) :
v = self.__jp.Test1.testStaticString("a", "b")
assert v[0] == 'a'
assert v[1] == 'b'
self.assertEqual(v[0], 'a')
self.assertEqual(v[1], 'b')
def testCallUnicodeString(self) :
v = self.__jp.Test1.testStaticString(u"a", u"b")
assert v[0] == 'a'
assert v[1] == 'b'
self.assertEqual(v[0], 'a')
self.assertEqual(v[1], 'b')
def testCallStringWithNone(self) :
v = self.__jp.Test1.testStaticString("a", None)
assert v[0] == 'a'
assert v[1] == None
self.assertEqual(v[0], 'a')
self.assertIsNone(v[1])
def testWithHolder(self) :
print 'testWithHolder'
holder = self.__jp.Holder()
holder.f = "ffff"
assert holder.f == "ffff"
self.__jp.Test1.testStaticHolder(holder)
self.assertEqual(holder.f, 'ffff')
result = self.__jp.Test1.testStaticHolder(holder)
self.assertEqual(result, 'ffff')
def testWithSubHolder(self) :
h2 = self.__jp.SubHolder()
h2.f = "subholder"
self.__jp.Test1.testStaticHolder(h2)
result = self.__jp.Test1.testStaticHolder(h2)
self.assertEqual(result, 'subholder')
def testCallWithArray(self) :
h2 = self.__jp.Test1()
@@ -129,10 +130,8 @@ def testCharAttribute(self) :
h = self.__jp.Test1()
h.charValue = u'b'
print h.charValue
print repr(h.charValue)
assert h.charValue == u'b'
self.assertEqual(h.charValue, 'b')
self.assertEqual(repr(h.charValue), "u'b'")
def testGetPrimitiveType(self) :
Integer = jpype.JClass("java.lang.Integer")
@@ -150,9 +149,7 @@ def testToString(self):
def testSuperToString(self):
h = self.__jp.Test2()
print h
assert str(h) == 'aaa'
del h
self.assertEqual(str(h), 'aaa')
# def testStringToConversion(self):
# try :
@@ -181,7 +178,6 @@ def testSuperToString(self):
# jpype.ConversionConfig.string = True
def testComplexMethodOvlerloading(self) :
c = self.__jp.TestOverloadC()
print c.foo(1)
assert c.foo(1) == "foo(int) in C: 1"
assert c.foo() == "foo() in A"
c = self.__jp.TestOverloadC()
self.assertEqual(c.foo(1), "foo(int) in C: 1")
self.assertEqual(c.foo(), "foo() in A")
@@ -31,7 +31,6 @@ def suite() :
pkgpath = os.path.dirname(jpypetest.__file__)
names = ["jpypetest.%s" % name for _, name,
_ in pkgutil.iter_modules([pkgpath])]
print names
test_suite = loader.loadTestsFromNames(names)
return test_suite

0 comments on commit daff8f5

Please sign in to comment.