|
1 | 1 | import re
|
2 | 2 | from pathlib import Path
|
3 |
| -from subprocess import STDOUT, check_output |
| 3 | +from subprocess import run |
4 | 4 |
|
5 | 5 | from jdk4py import JAVA, JAVA_VERSION
|
6 | 6 | from jdk4py._included_locales import INCLUDED_LOCALES
|
|
9 | 9 |
|
10 | 10 |
|
11 | 11 | def test_java_version() -> None:
|
12 |
| - output = check_output( # noqa: S603 |
| 12 | + completed_process = run( # noqa: S603 |
13 | 13 | [JAVA, "-version"],
|
14 |
| - stderr=STDOUT, |
| 14 | + capture_output=True, |
| 15 | + check=True, |
15 | 16 | text=True,
|
16 | 17 | )
|
17 |
| - match = re.match(r'^openjdk version "(?P<version>[^"]+)"', output) |
18 |
| - assert match, f"Unexpected output:\n{output}" |
| 18 | + match = re.match(r'^openjdk version "(?P<version>[^"]+)"', completed_process.stderr) |
| 19 | + assert match, f"Unexpected output:\n{completed_process.stdout}" |
19 | 20 | version = match.group("version")
|
20 | 21 | assert isinstance(version, str)
|
21 | 22 | assert tuple([int(number) for number in version.split(".")][:3]) == JAVA_VERSION
|
22 | 23 |
|
23 | 24 |
|
24 | 25 | def test_jar_execution() -> None:
|
25 |
| - output = check_output( # noqa: S603 |
| 26 | + completed_process = run( # noqa: S603 |
26 | 27 | [JAVA, "-jar", _TEST_RESOURCES_DIRECTORY / "HelloWorld.jar"],
|
27 |
| - stderr=STDOUT, |
| 28 | + capture_output=True, |
| 29 | + check=True, |
28 | 30 | text=True,
|
29 |
| - ).strip() |
30 |
| - assert output == "Hello, World" |
| 31 | + ) |
| 32 | + assert completed_process.stdout.strip() == "Hello, World" |
31 | 33 |
|
32 | 34 |
|
33 | 35 | def test_included_locales() -> None:
|
34 |
| - output = check_output( # noqa: S603 |
| 36 | + completed_process = run( # noqa: S603 |
35 | 37 | [JAVA, "-jar", _TEST_RESOURCES_DIRECTORY / "PrintAvailableLocales.jar"],
|
36 |
| - stderr=STDOUT, |
| 38 | + capture_output=True, |
| 39 | + check=True, |
37 | 40 | text=True,
|
38 |
| - ).strip() |
39 |
| - locales = {locale.replace("_", "-") for locale in output.splitlines()} |
| 41 | + ) |
| 42 | + locales = { |
| 43 | + locale.replace("_", "-") |
| 44 | + for locale in completed_process.stdout.strip().splitlines() |
| 45 | + } |
40 | 46 | assert locales.issuperset(INCLUDED_LOCALES)
|
0 commit comments