From ee4048f6b61463b381d516e4d74d4dcd2edfc655 Mon Sep 17 00:00:00 2001 From: Elmom Date: Wed, 13 Oct 2010 09:25:21 +0300 Subject: [PATCH] Moved testing code to another file for easier using outside MCAD --- openscad_testing.py | 49 +++++++++++++++++++++++++++++++++++++++++++++ test_mcad.py | 1 + 2 files changed, 50 insertions(+) create mode 100644 openscad_testing.py create mode 100644 test_mcad.py diff --git a/openscad_testing.py b/openscad_testing.py new file mode 100644 index 0000000..64d96c7 --- /dev/null +++ b/openscad_testing.py @@ -0,0 +1,49 @@ +import py + +from openscad_utils import * + + +temppath = py.test.ensuretemp('MCAD') + +def pytest_generate_tests(metafunc): + if "modpath" in metafunc.funcargnames: + for fpath, modnames in collect_test_modules().items(): + #os.system("cp %s %s/" % (fpath, temppath)) + if "modname" in metafunc.funcargnames: + for modname in modnames: + metafunc.addcall(funcargs=dict(modname=modname, modpath=fpath)) + else: + metafunc.addcall(funcargs=dict(modpath=fpath)) + + +def test_module_compile(modname, modpath): + tempname = modpath.basename + '-' + modname + '.scad' + fpath = temppath.join(tempname) + stlpath = temppath.join(tempname + ".stl") + f = fpath.open('w') + code = """ +//generated testfile +use <%s> + +%s(); +""" % (modpath, modname) + print code + f.write(code) + f.flush() + output = call_openscad(path=fpath, stlpath=stlpath, timeout=15) + print output + assert output[0] is 0 + for s in ("warning", "error"): + assert s not in output[2].strip().lower() + assert len(stlpath.readlines()) > 2 + +def test_file_compile(modpath): + stlpath = temppath.join(modpath.basename + "-test.stl") + output = call_openscad(path=modpath, stlpath=stlpath) + print output + assert output[0] is 0 + for s in ("warning", "error"): + assert s not in output[2].strip().lower() + assert len(stlpath.readlines()) == 2 + + diff --git a/test_mcad.py b/test_mcad.py new file mode 100644 index 0000000..7048842 --- /dev/null +++ b/test_mcad.py @@ -0,0 +1 @@ +from openscad_testing import *