forked from diara628/MCAD_old
-
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.
Added testing infra using py.test. Catches parse errors already, but …
…stl compiling tests fail
- Loading branch information
Showing
5 changed files
with
83 additions
and
18 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
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,14 +1,44 @@ | ||
import py | ||
|
||
from openscad_utils import * | ||
|
||
def pytest_generate_tests(metafunc): | ||
if "mod_name" in metafunc.funcargnames: | ||
for fpath, mod_names in collect_test_modules().items(): | ||
for mod_name in mod_names: | ||
metafunc.addcall(funcargs=dict(mod_name=mod_name, mod_file=fpath)) | ||
if "modpath" in metafunc.funcargnames: | ||
if "modname" in metafunc.funcargnames: | ||
for fpath, modnames in collect_test_modules().items(): | ||
for modname in modnames: | ||
metafunc.addcall(funcargs=dict(modname=modname, modpath=fpath)) | ||
else: | ||
dirpath = py.path.local("./") | ||
for fpath in dirpath.visit('*.scad'): | ||
metafunc.addcall(funcargs=dict(modpath=fpath)) | ||
|
||
temppath = py.test.ensuretemp('MCAD') | ||
|
||
def test_func(mod_name, mod_file, capfd): | ||
fpath = temppath.join(mod_file.base_name) | ||
|
||
call_openscad(path=fpath) | ||
def test_compile(modname, modpath): | ||
tempname = "test_" + modpath.basename + modname | ||
fpath = temppath.join(tempname) | ||
stlpath = temppath.join(tempname + ".stl") | ||
f = fpath.open('w') | ||
f.write(""" | ||
//generated testfile | ||
include <%s> | ||
%s() | ||
""" % (modpath, modname)) | ||
f.flush | ||
output = call_openscad(path=fpath, stlpath=stlpath) | ||
print output | ||
assert output[0] is 0 | ||
assert "warning" or "error" not in output[2].strip().lowercase() | ||
assert len(stlpath.readlines()) > 2 | ||
|
||
def test_compile_default(modpath): | ||
tempname = "test_" + modpath.basename | ||
stlpath = temppath.join(tempname + ".stl") | ||
output = call_openscad(path=modpath, stlpath=stlpath) | ||
print output | ||
assert output[0] is 0 | ||
assert "warning" or "error" not in output[2].strip().lowercase() | ||
|
||
|