generated from par-tec/python-cookiecutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f52c96
commit e594a9d
Showing
8 changed files
with
104 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
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,34 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.mycompany.app</groupId> | ||
<artifactId>my-app</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>30.1-jre</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<minimizeJar>true</minimizeJar> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,2 @@ | ||
jpype1 | ||
cffi |
Binary file not shown.
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,16 @@ | ||
import jpype | ||
|
||
def test_noop(): | ||
|
||
jpype.startJVM(jpype.getDefaultJVMPath()) | ||
|
||
Random = jpype.JClass('java.util.Random') | ||
String = jpype.JClass('java.lang.String') | ||
System = jpype.JClass('java.lang.System') | ||
# Create an instance of java.util.Random | ||
random = Random() | ||
for _ in range(20): | ||
System.out.println(String.format("Random number: %d", random.nextInt())) | ||
|
||
# Shutdown the JVM | ||
jpype.shutdownJVM() |
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,50 @@ | ||
import os | ||
import pytest | ||
import jpype | ||
from jpype import startJVM, shutdownJVM | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=False) | ||
def setupJVM(): | ||
""" | ||
Setup a JVM configured to use the Europe/Rome timezone. | ||
""" | ||
os.environ["TZ"] = "Europe/Rome" | ||
startJVM( | ||
convertStrings=False, | ||
classpath=["java-project/target/guava-28.2-android.jar"], | ||
) | ||
yield | ||
shutdownJVM() | ||
|
||
|
||
def test_guava_ascii(setupJVM): | ||
Ascii = jpype.JClass("com.google.common.base.Ascii") | ||
assert Ascii.toLowerCase("EuroPython") == "europython" | ||
|
||
|
||
@pytest.mark.parametrize("inet_addr,is_valid", [ | ||
("1.2.3.4", True), | ||
("3ffe::1", True), | ||
("3ffe::1z", False), | ||
("333.1.1.1", False), | ||
]) | ||
def test_InetAddress(setupJVM, inet_addr, is_valid): | ||
InetAddress = jpype.JClass("com.google.common.net.InetAddresses") | ||
assert InetAddress.isInetAddress(inet_addr) == is_valid | ||
|
||
|
||
def test_automatic_imports(setupJVM): | ||
java = jpype.JPackage("java") | ||
from java.lang import String | ||
|
||
assert String.format("Hello, %s", "World") == "Hello, World" | ||
|
||
|
||
def test_bigdecimal(setupJVM): | ||
BigDecimal = jpype.JClass("java.math.BigDecimal") | ||
a, b = 0.1, 0.2 | ||
b_a = BigDecimal(a) | ||
b_b = BigDecimal(b) | ||
assert b_a.add(b_b) == BigDecimal(a+b) | ||
raise ValueError("This test is expected to fail") |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tox] | ||
envlist = py3, safety | ||
envlist = py3 | ||
|
||
# By default, we do not publish a module. | ||
skipsdist=True | ||
|