-
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
2 changed files
with
61 additions
and
0 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,6 @@ | ||
from setuptools import setup | ||
from Cython.Build import cythonize | ||
|
||
setup( | ||
ext_modules = cythonize("/home/joepers/code/cpc/tests/input/trouble.pyx") | ||
) |
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,55 @@ | ||
import os | ||
import pytest | ||
from pathlib import Path | ||
|
||
|
||
class_declaration = ("pure_python", "cython") | ||
no_getter = ("skip", "convert") | ||
# output_mod_only = (True, False) | ||
|
||
|
||
test_path = Path(__file__).parent | ||
base_path = test_path.parent | ||
|
||
|
||
def test_compilation(): | ||
exit_code = os.system(f"python3 {test_path}/setup.py build_ext --inplace") | ||
assert exit_code == 0 | ||
|
||
|
||
class TestArgs: | ||
def test_class_declaration(self, tmp_path): | ||
test_output = tmp_path / "test_output" | ||
test_output.mkdir() | ||
for arg in class_declaration: | ||
os.system( | ||
f"python3 {base_path}/converter.py -i {test_path}/input -o {test_output} --class_declaration {arg}" | ||
) | ||
good_fp = f"{test_path}/good_outputs/{arg}.py" | ||
with open(good_fp) as fff: | ||
good = fff.read() | ||
|
||
output_fp = f"{test_output}/input/trouble.pyx" | ||
|
||
with open(output_fp) as fff: | ||
for index, line in enumerate(fff.read().splitlines()): | ||
assert line == good.splitlines()[index] | ||
|
||
def test_no_getter(self, tmp_path): | ||
test_output = tmp_path / "test_output" | ||
test_output.mkdir() | ||
for arg in no_getter: | ||
os.system( | ||
f"python3 {base_path}/converter.py -i {test_path}/input -o {test_output} --no_getter {arg}" | ||
) | ||
good_fp = f"{test_path}/good_outputs/{arg}.py" | ||
with open(good_fp) as fff: | ||
good = fff.read() | ||
|
||
output_fp = f"{test_output}/input/trouble.pyx" | ||
|
||
with open(output_fp) as fff: | ||
for index, line in enumerate(fff.read().splitlines()): | ||
assert line == good.splitlines()[index] | ||
|
||
def output_mod_only(self): ... |