Better test names, support for Mac

This commit is contained in:
Marius Kintel 2011-09-08 03:52:11 +02:00
parent 47876c4a7e
commit 60490ebd2c
3 changed files with 12 additions and 7 deletions

View file

@ -1,5 +1,5 @@
import py import py
import os.path
from openscad_utils import * from openscad_utils import *
@ -8,12 +8,14 @@ temppath = py.test.ensuretemp('MCAD')
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
if "modpath" in metafunc.funcargnames: if "modpath" in metafunc.funcargnames:
for fpath, modnames in collect_test_modules().items(): for fpath, modnames in collect_test_modules().items():
basename = os.path.splitext(os.path.split(str(fpath))[1])[0]
#os.system("cp %s %s/" % (fpath, temppath)) #os.system("cp %s %s/" % (fpath, temppath))
if "modname" in metafunc.funcargnames: if "modname" in metafunc.funcargnames:
for modname in modnames: for modname in modnames:
metafunc.addcall(funcargs=dict(modname=modname, modpath=fpath)) print modname
metafunc.addcall(id=basename+"/"+modname, funcargs=dict(modname=modname, modpath=fpath))
else: else:
metafunc.addcall(funcargs=dict(modpath=fpath)) metafunc.addcall(id=os.path.split(str(fpath))[1], funcargs=dict(modpath=fpath))
def test_module_compile(modname, modpath): def test_module_compile(modname, modpath):

View file

@ -1,4 +1,4 @@
import py, re, os, signal, time, commands import py, re, os, signal, time, commands, sys
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
mod_re = (r"\bmodule\s+(", r")\s*\(\s*") mod_re = (r"\bmodule\s+(", r")\s*\(\s*")
@ -30,7 +30,9 @@ def collect_test_modules(dirpath=None):
class Timeout(Exception): pass class Timeout(Exception): pass
def call_openscad(path, stlpath, timeout=5): def call_openscad(path, stlpath, timeout=5):
command = ['openscad', '-s', str(stlpath), str(path)] if sys.platform == 'darwin': exe = 'OpenSCAD.app/Contents/MacOS/OpenSCAD'
else: exe = 'openscad'
command = [exe, '-s', str(stlpath), str(path)]
print command print command
if timeout: if timeout:
try: try:

View file

@ -1,15 +1,16 @@
import py import py
import os.path
dirpath = py.path.local("./") dirpath = py.path.local("./")
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
if "filename" in metafunc.funcargnames: if "filename" in metafunc.funcargnames:
for fpath in dirpath.visit('*.scad'): for fpath in dirpath.visit('*.scad'):
metafunc.addcall(funcargs=dict(filename=fpath.basename)) metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))
for fpath in dirpath.visit('*.py'): for fpath in dirpath.visit('*.py'):
name = fpath.basename name = fpath.basename
if not (name.startswith('test_') or name.startswith('_')): if not (name.startswith('test_') or name.startswith('_')):
metafunc.addcall(funcargs=dict(filename=fpath.basename)) metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))
def test_README(filename): def test_README(filename):
README = dirpath.join('README').read() README = dirpath.join('README').read()