-
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
Showing
11 changed files
with
227 additions
and
52 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[MESSAGES CONTROL] | ||
disable=missing-module-docstring,missing-class-docstring,missing-function-docstring,line-too-long,raise-missing-from,too-few-public-methods,too-many-return-statements | ||
disable=missing-module-docstring,missing-class-docstring,missing-function-docstring,line-too-long,raise-missing-from,too-few-public-methods,too-many-return-statements,duplicate-code |
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
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 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Unit test file. | ||
""" | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
import unittest | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
|
||
HERE = Path(__file__).parent | ||
PROJECT_ROOT = HERE.parent | ||
DEMO_PY = PROJECT_ROOT / "src/python_compile/assets/demo_http_server.py" | ||
|
||
|
||
class CliNativetester(unittest.TestCase): | ||
"""Main tester class.""" | ||
|
||
def test_cli(self) -> None: | ||
"""Test command line interface (CLI).""" | ||
with TemporaryDirectory() as tmp_dir: | ||
os.chdir(tmp_dir) | ||
try: | ||
cmd_list = [ | ||
"python-compile", | ||
"--input", | ||
str(DEMO_PY), | ||
] | ||
cmd_str = subprocess.list2cmdline(cmd_list) | ||
print(f"Running: {cmd_str}") | ||
rtn = os.system(" ".join(cmd_list)) | ||
self.assertEqual(0, rtn) | ||
expected_path_gz: Path = Path("demo_http_server.bin.gz") | ||
self.assertTrue(expected_path_gz.exists()) | ||
if sys.platform == "win32": | ||
expected_path = Path("demo_http_server.exe") | ||
else: | ||
expected_path = Path("demo_http_server.bin") | ||
self.assertTrue(expected_path.exists()) | ||
finally: | ||
os.chdir(PROJECT_ROOT) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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,41 @@ | ||
""" | ||
Unit test file. | ||
""" | ||
|
||
import os | ||
import subprocess | ||
import unittest | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
|
||
|
||
class NativeTester(unittest.TestCase): | ||
"""Main tester class.""" | ||
|
||
def test_compile(self) -> None: | ||
"""Test command line interface (CLI).""" | ||
with TemporaryDirectory() as tmp_dir: | ||
prev_dir = os.getcwd() | ||
os.chdir(tmp_dir) | ||
try: | ||
cmd_list = [ | ||
"python-compile", | ||
"--input", | ||
"src/python_compile/assets/demo_http_server.py", | ||
"--os", | ||
"debian", | ||
] | ||
cmd_str = subprocess.list2cmdline(cmd_list) | ||
print(f"Running: {cmd_str}") | ||
rtn = os.system(" ".join(cmd_list)) | ||
self.assertEqual(0, rtn) | ||
expected_path_gz: Path = Path("demo_http_server.bin.gz") | ||
self.assertTrue(expected_path_gz.exists()) | ||
expected_path = Path("demo_http_server.bin") | ||
self.assertTrue(expected_path.exists()) | ||
finally: | ||
os.chdir(prev_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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,45 @@ | ||
""" | ||
Unit test file. | ||
""" | ||
|
||
import os | ||
import sys | ||
import unittest | ||
from pathlib import Path | ||
from pprint import pprint | ||
from tempfile import TemporaryDirectory | ||
|
||
from python_compile.cli import Args, run | ||
|
||
HERE = Path(__file__).parent | ||
PROJECT_ROOT = HERE.parent | ||
DEMO_PY = PROJECT_ROOT / "src/python_compile/assets/demo_http_server.py" | ||
|
||
|
||
class MainTester(unittest.TestCase): | ||
"""Main tester class.""" | ||
|
||
def test_run_main(self) -> None: | ||
"""Test command line interface (CLI).""" | ||
with TemporaryDirectory(ignore_cleanup_errors=True) as tmp_dir: | ||
prev_dir = os.getcwd() | ||
os.chdir(tmp_dir) | ||
if sys.platform == "win32": | ||
expected_path = "demo_http_server.exe" | ||
else: | ||
expected_path = "demo_http_server.bin" | ||
try: | ||
args = Args(app_py=DEMO_PY) | ||
rtn = run(args) | ||
self.assertEqual(0, rtn) | ||
files = os.listdir(tmp_dir) | ||
pprint(files) | ||
self.assertTrue( | ||
expected_path in files, f"{expected_path} not found in {files}" | ||
) | ||
finally: | ||
os.chdir(prev_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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,43 @@ | ||
""" | ||
Unit test file. | ||
""" | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
import unittest | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
|
||
|
||
class NativeTester(unittest.TestCase): | ||
"""Main tester class.""" | ||
|
||
def test_compile(self) -> None: | ||
"""Test command line interface (CLI).""" | ||
with TemporaryDirectory() as tmp_dir: | ||
prev_dir = os.getcwd() | ||
os.chdir(tmp_dir) | ||
try: | ||
cmd_list = [ | ||
"python-compile", | ||
"--input", | ||
"src/python_compile/assets/demo_http_server.py", | ||
] | ||
cmd_str = subprocess.list2cmdline(cmd_list) | ||
print(f"Running: {cmd_str}") | ||
rtn = os.system(" ".join(cmd_list)) | ||
self.assertEqual(0, rtn) | ||
expected_path_gz: Path = Path("demo_http_server.bin.gz") | ||
self.assertTrue(expected_path_gz.exists()) | ||
if sys.platform == "win32": | ||
expected_path = Path("demo_http_server.exe") | ||
else: | ||
expected_path = Path("demo_http_server.bin") | ||
self.assertTrue(expected_path.exists()) | ||
finally: | ||
os.chdir(prev_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |