Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Aug 22, 2024
1 parent b3a4802 commit d171b50
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
13 changes: 13 additions & 0 deletions test/jpypetest/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# See NOTICE file for details.
#
# *****************************************************************************
from functools import lru_cache

import pytest
import _jpype
Expand Down Expand Up @@ -142,3 +143,15 @@ def assertElementsAlmostEqual(self, a, b):

def useEqualityFunc(self, func):
return UseFunc(self, func, 'assertEqual')


@lru_cache(1)
def java_version():
import subprocess
import sys
java_version = str(subprocess.check_output([sys.executable, "-c",
"import jpype; jpype.startJVM(); "
"print(jpype.java.lang.System.getProperty('java.version'))"]),

Check warning

Code scanning / CodeQL

Implicit string concatenation in a list Warning test

Implicit string concatenation. Maybe missing a comma?
encoding='ascii')
print("java_version:", java_version)
return tuple(map(int, java_version.split(".")))
11 changes: 0 additions & 11 deletions test/jpypetest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# See NOTICE file for details.
#
# *****************************************************************************
from functools import cache

import pytest

Expand Down Expand Up @@ -46,13 +45,3 @@ def common_opts(request):
request.cls._convertStrings = request.config.getoption("--convertStrings")
request.cls._jacoco = request.config.getoption("--jacoco")
request.cls._checkjni = request.config.getoption("--checkjni")


#@pytest.fixture(scope="session", autouse=True)
@cache
def java_version():
print("hi from java_version()")
import subprocess, sys
java_version = str(subprocess.check_output([sys.executable, "-c",
"import jpype; jpype.startJVM(); print(jpype.java.lang.System.getProperty('java.version'))"]))
return java_version.split(".")
4 changes: 2 additions & 2 deletions test/jpypetest/test_sql_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
db_name = "jdbc:sqlite::memory:"

def setUpModule(module):
from conftest import java_version
from common import java_version
version = java_version()
print("setup module: jdk version", version)
if version[0] == "8":
if version[0] == 8:
pytest.skip("jdk8 unsupported", allow_module_level=True)

# raise common.unittest.SkipTest("SQLite unsupported for JDK 8.")
Expand Down

0 comments on commit d171b50

Please sign in to comment.