-
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from chezou/jpype
feat: Use jpype instead of subprocess
- Loading branch information
Showing
6 changed files
with
118 additions
and
158 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
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,21 @@ | ||
import unittest | ||
from pathlib import Path | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
import tabula | ||
|
||
|
||
class TestReadPdfJarPath(unittest.TestCase): | ||
def setUp(self): | ||
self.pdf_path = "tests/resources/data.pdf" | ||
|
||
@patch("tabula.io.TabulaVm._jar_path") | ||
def test_read_pdf_with_jar_path(self, jar_func): | ||
jar_func.return_value = "/tmp/tabula-java.jar" | ||
|
||
with pytest.raises(ImportError): | ||
tabula.read_pdf(self.pdf_path, encoding="utf-8") | ||
file_name = Path(tabula.io.jpype.getClassPath()).name | ||
self.assertEqual(file_name, "tabula-java.jar") |
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,30 @@ | ||
import platform | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
import tabula | ||
|
||
|
||
class TestReadPdfJarPath(unittest.TestCase): | ||
def setUp(self): | ||
self.pdf_path = "tests/resources/data.pdf" | ||
|
||
@patch("tabula.io.jpype.startJVM") | ||
def test_read_pdf_with_silent_true(self, jvm_func): | ||
with pytest.raises(ImportError): | ||
tabula.read_pdf(self.pdf_path, encoding="utf-8", silent=True) | ||
|
||
target_args = [] | ||
if platform.system() == "Darwin": | ||
target_args += ["-Djava.awt.headless=true"] | ||
target_args += [ | ||
"-Dfile.encoding=UTF8", | ||
"-Dorg.slf4j.simpleLogger.defaultLogLevel=off", | ||
"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog", | ||
] | ||
jvm_func.assert_called_once_with( | ||
*target_args, | ||
convertStrings=False, | ||
) |
Oops, something went wrong.