Skip to content

Commit 60490eb

Browse files
committed
Better test names, support for Mac
1 parent 47876c4 commit 60490eb

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

openscad_testing.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import py
2-
2+
import os.path
33
from openscad_utils import *
44

55

@@ -8,12 +8,14 @@
88
def pytest_generate_tests(metafunc):
99
if "modpath" in metafunc.funcargnames:
1010
for fpath, modnames in collect_test_modules().items():
11+
basename = os.path.splitext(os.path.split(str(fpath))[1])[0]
1112
#os.system("cp %s %s/" % (fpath, temppath))
1213
if "modname" in metafunc.funcargnames:
1314
for modname in modnames:
14-
metafunc.addcall(funcargs=dict(modname=modname, modpath=fpath))
15+
print modname
16+
metafunc.addcall(id=basename+"/"+modname, funcargs=dict(modname=modname, modpath=fpath))
1517
else:
16-
metafunc.addcall(funcargs=dict(modpath=fpath))
18+
metafunc.addcall(id=os.path.split(str(fpath))[1], funcargs=dict(modpath=fpath))
1719

1820

1921
def test_module_compile(modname, modpath):

openscad_utils.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import py, re, os, signal, time, commands
1+
import py, re, os, signal, time, commands, sys
22
from subprocess import Popen, PIPE
33

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

3232
def call_openscad(path, stlpath, timeout=5):
33-
command = ['openscad', '-s', str(stlpath), str(path)]
33+
if sys.platform == 'darwin': exe = 'OpenSCAD.app/Contents/MacOS/OpenSCAD'
34+
else: exe = 'openscad'
35+
command = [exe, '-s', str(stlpath), str(path)]
3436
print command
3537
if timeout:
3638
try:

test_docs.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import py
2+
import os.path
23

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

56
def pytest_generate_tests(metafunc):
67
if "filename" in metafunc.funcargnames:
78
for fpath in dirpath.visit('*.scad'):
8-
metafunc.addcall(funcargs=dict(filename=fpath.basename))
9+
metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))
910
for fpath in dirpath.visit('*.py'):
1011
name = fpath.basename
1112
if not (name.startswith('test_') or name.startswith('_')):
12-
metafunc.addcall(funcargs=dict(filename=fpath.basename))
13+
metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename))
1314

1415
def test_README(filename):
1516
README = dirpath.join('README').read()

0 commit comments

Comments
 (0)