Skip to content

Commit

Permalink
Better test names, support for Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
kintel committed Sep 8, 2011
1 parent 47876c4 commit 60490eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions openscad_testing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import py

import os.path
from openscad_utils import *


Expand All @@ -8,12 +8,14 @@
def pytest_generate_tests(metafunc):
if "modpath" in metafunc.funcargnames:
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))
if "modname" in metafunc.funcargnames:
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:
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):
Expand Down
6 changes: 4 additions & 2 deletions openscad_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import py, re, os, signal, time, commands
import py, re, os, signal, time, commands, sys
from subprocess import Popen, PIPE

mod_re = (r"\bmodule\s+(", r")\s*\(\s*")
Expand Down Expand Up @@ -30,7 +30,9 @@ def collect_test_modules(dirpath=None):
class Timeout(Exception): pass

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
if timeout:
try:
Expand Down
5 changes: 3 additions & 2 deletions test_docs.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import py
import os.path

dirpath = py.path.local("./")

def pytest_generate_tests(metafunc):
if "filename" in metafunc.funcargnames:
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'):
name = fpath.basename
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):
README = dirpath.join('README').read()
Expand Down

0 comments on commit 60490eb

Please sign in to comment.