-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve JVM exceptions (#1037)
This PR improves the compatibility JVM error messages.
- Loading branch information
Showing
4 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
import jpyinterpreter | ||
import jpype | ||
|
||
class Java17Runtime: | ||
def version(self): | ||
class Version: | ||
def feature(self): | ||
return 17 | ||
return Version() | ||
|
||
class Java10Runtime: | ||
def version(self): | ||
class Version: | ||
def feature(self): | ||
return 10 | ||
return Version() | ||
|
||
class Java9Runtime: | ||
def version(self): | ||
class Version: | ||
def major(self): | ||
return 17 | ||
return Version() | ||
|
||
class Java8Runtime: | ||
pass | ||
|
||
def test_jvm_setup(): | ||
jpyinterpreter.ensure_valid_jvm(Java17Runtime()) | ||
with pytest.raises(jpyinterpreter.InvalidJVMVersionError): | ||
jpyinterpreter.ensure_valid_jvm(Java8Runtime()) | ||
with pytest.raises(jpyinterpreter.InvalidJVMVersionError): | ||
jpyinterpreter.ensure_valid_jvm(Java9Runtime()) | ||
with pytest.raises(jpyinterpreter.InvalidJVMVersionError): | ||
jpyinterpreter.ensure_valid_jvm(Java10Runtime()) | ||
|
||
def jvm_not_found(): | ||
raise jpype.JVMNotFoundException() | ||
|
||
def test_jvm_get_default_jvm_path(): | ||
jpyinterpreter.get_default_jvm_path() | ||
with pytest.raises(jpyinterpreter.InvalidJVMVersionError): | ||
jpyinterpreter.get_default_jvm_path(jvm_not_found) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters