Fixed long literals for Python3 compatibility

This commit is contained in:
Juan Toledo 2017-08-21 18:00:04 +02:00
parent e3dad6b5f5
commit a912e1a87e
2 changed files with 17 additions and 3 deletions

View File

@ -4,6 +4,13 @@ from __future__ import absolute_import
import unittest
from jnius.reflect import autoclass
try:
long
except NameError:
# Python 3
long = int
class BasicsTest(unittest.TestCase):
def test_static_methods(self):
@ -102,7 +109,7 @@ class BasicsTest(unittest.TestCase):
self.assertEquals(test.methodParamsZBCSIJFD(
True, 127, 'k', 32767, 2147483467, 9223372036854775807, 1.23456789, 1.23456789), True)
self.assertEquals(test.methodParamsZBCSIJFD(
True, 127L, 'k', 32767L, 2147483467L, 9223372036854775807, 1.23456789, 1.23456789), True)
True, long(127), 'k', long(32767), long(2147483467), 9223372036854775807, 1.23456789, 1.23456789), True)
self.assertEquals(test.methodParamsString('helloworld'), True)
self.assertEquals(test.methodParamsArrayI([1, 2, 3]), True)
self.assertEquals(test.methodParamsArrayString([

View File

@ -4,6 +4,13 @@ from __future__ import absolute_import
import unittest
from jnius.reflect import autoclass
try:
long
except NameError:
# Python 3
long = int
class MultipleSignature(unittest.TestCase):
def test_multiple_constructors(self):
@ -46,7 +53,7 @@ class MultipleSignature(unittest.TestCase):
def test_multiple_methods_varargs_long(self):
MultipleMethods = autoclass('org.jnius.MultipleMethods')
self.assertEqual(MultipleMethods.resolve(1L, 2L, 3L), 'resolved varargs')
self.assertEqual(MultipleMethods.resolve(long(1), long(2), long(3)), 'resolved varargs')
def test_multiple_methods_two_args_and_varargs(self):
MultipleMethods = autoclass('org.jnius.MultipleMethods')
@ -55,7 +62,7 @@ class MultipleSignature(unittest.TestCase):
def test_multiple_methods_one_int_one_small_long_and_a_string(self):
MultipleMethods = autoclass('org.jnius.MultipleMethods')
self.assertEqual(MultipleMethods.resolve(
1, 1L, "one"), "resolved one int, one long and a string")
1, long(1), "one"), "resolved one int, one long and a string")
def test_multiple_methods_one_int_one_actual_long_and_a_string(self):
MultipleMethods = autoclass('org.jnius.MultipleMethods')