Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSchiff authored Jul 1, 2024
1 parent ab5e02a commit 319169e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/setup.py
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")
)
55 changes: 55 additions & 0 deletions tests/test_all.py
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): ...

0 comments on commit 319169e

Please sign in to comment.