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.
- Loading branch information
Showing
2 changed files
with
44 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,30 @@ | ||
import py, re | ||
|
||
mod_re = (r"\bmodule\s+(", r")\s*\(\s*") | ||
func_re = (r"\bfunction\s+(", r")\s*\(") | ||
|
||
def extract_mod_names(fpath, name_re=r"\w+"): | ||
regex = name_re.join(mod_re) | ||
print regex | ||
matcher = re.compile(regex) | ||
return (m.group(1) for m in matcher.finditer(fpath.read())) | ||
|
||
def extract_func_names(fpath, name_re=r"\w+"): | ||
regex = name_re.join(func_re) | ||
print regex | ||
matcher = re.compile(regex) | ||
return (m.group(1) for m in matcher.finditer(fpath.read())) | ||
|
||
def collect_test_modules(): | ||
dirpath = py.path.local("./") | ||
print "Collecting openscad test module names" | ||
|
||
test_files = {} | ||
for fpath in dirpath.visit('*.scad'): | ||
#print fpath | ||
modules = extract_mod_names(fpath, r"test\w*") | ||
#functions = extract_func_names(fpath, r"test\w*") | ||
test_files[fpath] = modules | ||
return test_files | ||
|
||
collect_test_modules() |
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,14 @@ | ||
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)) | ||
|
||
temppath = py.test.ensuretemp('MCAD') | ||
|
||
def test_func(mod_name, mod_file, capfd): | ||
fpath = temppath.join(mod_file.base_name) | ||
|
||
call_openscad(path=fpath) |