Skip to content

Commit

Permalink
activate coveralls again
Browse files Browse the repository at this point in the history
  • Loading branch information
tshirtman committed Dec 6, 2019
1 parent bf17b10 commit c31cc2a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 40 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
plugins = Cython.Coverage
source = jnius/
omit =
tests
*__init__.py
28 changes: 9 additions & 19 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
"%VS140COMNTOOLS%../../VC/vcvarsall.bat"
echo "$INCLUDE"
set INCLUDE "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
pip install --timeout=120 -U setuptools cython
pip install --timeout=120 -vv .[dev,ci]
Expand All @@ -72,27 +71,18 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
$env:PATH +=";$env:JAVA_HOME\jre\bin\server\;$env:JAVA_HOME\jre\bin\client\;$env:JAVA_HOME\bin\server\"
$env:CLASSPATH ="../build/test-classes;../build/classes"
$env:CLASSPATH ="./build/test-classes;./build/classes"
ant all
cd tests
pytest -v
pytest
- name: test
if: matrix.os == 'ubuntu-latest'
run: |
ant all
cd tests
CLASSPATH=../build/test-classes:../build/classes pytest -v
- name: test
if: matrix.os == 'macOs-latest'
if: matrix.os != 'windows-latest'
run: |
ant all
cd tests
CLASSPATH=../build/test-classes:../build/classes python -m pytest -v
CLASSPATH=./build/test-classes:./build/classes python -m pytest
# - name: coveralls
# run: python -m coveralls
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: coveralls
run: python -m coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_PARALLEL: true
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --cov=jnius -v tests
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def compile_native_invocation_handler(*possible_homes):
# generate the config.pxi
with open(join(dirname(__file__), 'jnius', 'config.pxi'), 'w') as fd:
fd.write('DEF JNIUS_PLATFORM = {0!r}\n\n'.format(PLATFORM))
if getenv('GITHUB_WORKFLOW') == 'Tests':
print("GITHUB_WORKFLOW Tests detected, tracing cython code for coverage")
fd.write('# cython: linetrace=True')
fd.write('# distutils: define_macros=CYTHON_TRACE=1')
if not PY2:
fd.write('# cython: language_level=3\n\n')
fd.write('DEF JNIUS_PYTHON3 = True\n\n')
Expand Down
Empty file added tests/__init__.py
Empty file.
8 changes: 4 additions & 4 deletions tests/test_int_vs_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from jnius import autoclass, cast, PythonJavaClass, java_method


class TestImplemIterator(PythonJavaClass):
class _TestImplemIterator(PythonJavaClass):
__javainterfaces__ = ['java/util/ListIterator']


class TestImplem(PythonJavaClass):
class _TestImplem(PythonJavaClass):
__javainterfaces__ = ['java/util/List']

def __init__(self, *args):
super(TestImplem, self).__init__(*args)
super(_TestImplem, self).__init__(*args)
self.data = list(args)

@java_method('()I')
Expand Down Expand Up @@ -39,7 +39,7 @@ def test_reverse(self):
Collections = autoclass('java.util.Collections')
List = autoclass('java.util.List')
pylist = list(range(10))
a = TestImplem(*pylist)
a = _TestImplem(*pylist)
self.assertEqual(a.data, pylist)
self.assertEqual(str(a.data), '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]')

Expand Down
18 changes: 9 additions & 9 deletions tests/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
print('1: declare a TestImplem that implement Collection')


class TestImplemIterator(PythonJavaClass):
class _TestImplemIterator(PythonJavaClass):
__javainterfaces__ = [
#'java/util/Iterator',
'java/util/ListIterator', ]
Expand Down Expand Up @@ -55,16 +55,16 @@ def set(self, obj):
self.collection.data[self.index - 1] = obj


class TestImplem(PythonJavaClass):
class _TestImplem(PythonJavaClass):
__javainterfaces__ = ['java/util/List']

def __init__(self, *args):
super(TestImplem, self).__init__(*args)
super(_TestImplem, self).__init__(*args)
self.data = list(args)

@java_method('()Ljava/util/Iterator;')
def iterator(self):
it = TestImplemIterator(self)
it = _TestImplemIterator(self)
return it

@java_method('()Ljava/lang/String;')
Expand All @@ -91,17 +91,17 @@ def toArray(self):

@java_method('()Ljava/util/ListIterator;')
def listIterator(self):
it = TestImplemIterator(self)
it = _TestImplemIterator(self)
return it

@java_method('(I)Ljava/util/ListIterator;',
name='ListIterator')
def listIteratorI(self, index):
it = TestImplemIterator(self, index)
it = _TestImplemIterator(self, index)
return it


class TestBadSignature(PythonJavaClass):
class _TestBadSignature(PythonJavaClass):
__javainterfaces__ = ['java/util/List']

@java_method('(Landroid/bluetooth/BluetoothDevice;IB[])V')
Expand All @@ -110,7 +110,7 @@ def bad_signature(self, *args):


print('2: instantiate the class, with some data')
a = TestImplem(*list(range(10)))
a = _TestImplem(*list(range(10)))
print(a)
print(dir(a))

Expand Down Expand Up @@ -158,7 +158,7 @@ def bad_signature(self, *args):
# test bad signature
threw = False
try:
TestBadSignature()
_TestBadSignature()
except Exception:
threw = True

Expand Down
16 changes: 8 additions & 8 deletions tests/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
JString = autoclass('java/lang/String')
JListIterator = autoclass("java.util.ListIterator")

class TestImplemIterator(PythonJavaClass):
class _TestImplemIterator(PythonJavaClass):
__javainterfaces__ = [
'java/util/ListIterator', ]

def __init__(self, collection, index=0):
super(TestImplemIterator, self).__init__()
super(_TestImplemIterator, self).__init__()
self.collection = collection
self.index = index

Expand Down Expand Up @@ -54,16 +54,16 @@ def set(self, obj):
self.collection.data[self.index - 1] = obj


class TestImplem(PythonJavaClass):
class _TestImplem(PythonJavaClass):
__javainterfaces__ = ['java/util/List']

def __init__(self, *args):
super(TestImplem, self).__init__(*args)
super(_TestImplem, self).__init__(*args)
self.data = list(args)

@with_signature(autoclass("java.util.Iterator"), [])
def iterator(self):
it = TestImplemIterator(self)
it = _TestImplemIterator(self)
return it

@with_signature(JString, [])
Expand All @@ -90,14 +90,14 @@ def toArray(self):

@with_signature(JListIterator, [])
def listIterator(self):
it = TestImplemIterator(self)
it = _TestImplemIterator(self)
return it

# TODO cover this case of listIterator.
@java_method(signature(JListIterator, [jint]),
name='ListIterator')
def listIteratorI(self, index):
it = TestImplemIterator(self, index)
it = _TestImplemIterator(self, index)
return it


Expand All @@ -107,7 +107,7 @@ class SignaturesTest(unittest.TestCase):

def test_construct_stack_from_testimplem(self):
Stack = autoclass("java.util.Stack")
pyjlist = TestImplem(1, 2, 3, 4, 5, 6, 7)
pyjlist = _TestImplem(1, 2, 3, 4, 5, 6, 7)
stack = Stack()
stack.addAll(pyjlist)
self.assertEquals(7, pyjlist.size())
Expand Down

0 comments on commit c31cc2a

Please sign in to comment.