Skip to content

Commit 2bee648

Browse files
committed
-trimmed test scope
-added travis CI testing files
1 parent e65243c commit 2bee648

File tree

8 files changed

+34
-11
lines changed

8 files changed

+34
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.x3g
55
/build
66
*egg-info
7+
.coverage

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# vim ft=yaml
2+
# travis-ci.org definition for stl_tools build
3+
#
4+
5+
language: python
6+
python:
7+
- "2.7"
8+
- "3.2"
9+
- "3.3"
10+
# command to install dependencies
11+
install:
12+
- "pip install -r requirements.txt --use-mirrors"
13+
- "sudo python setup.py build install"
14+
# command to run tests
15+
script: nosetests

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
test:
2+
nosetests stl_tools
3+
4+
coverage:
5+
nosetests stl_tools --with-coverage --cover-package=stl_tools

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies above and install the library.
3636
This will also install the
3737
command line script `image2stl` into the `Python/Scripts` directory.
3838

39-
Automatic tests can be perfomed by running `stl_tools/test/test_model.py` from within the test directory.
39+
Automatic tests can be perfomed by running `stl_tools/test/test_stl.py`.
4040

4141
## Quickstart Examples:
4242

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
matplotlib>=1.2
2+
numpy>=1.7
3+
scipy>=0.12

stl_tools/image2stl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def image2stl():
5050
if L > 2:
5151
if len(w) >= L:
5252
A = np.sum([float(w[i]) * A[:, :, i]
53-
for i in xrange(A.shape[-1])], axis=0)
53+
for i in range(A.shape[-1])], axis=0)
5454
else:
5555
A = A.mean(axis=2)
5656

stl_tools/test/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
from numpy2stl import numpy2stl
2-
from text2png import text2png, text2array

stl_tools/test/test_stl.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,19 @@ def test_png(self):
2828
""" Tests creation of an STL from a PNG.
2929
Covers the text2array function.
3030
"""
31-
31+
output_name = "OUT_.stl"
3232
# test ascii output
3333
A = imresize([[0, 1], [1, 0]], (64, 64))
34-
numpy2stl(A, "OUT_.stl", scale=0.05, mask_val=3., ascii=True)
35-
os.path.exists("OUT_.stl")
34+
numpy2stl(A, output_name, scale=0.05, mask_val=3., ascii=True)
35+
assert os.path.exists(output_name)
36+
assert os.stat(output_name).st_size > 1500000
3637

3738
# test binary output
3839
A = imresize([[0, 1], [1, 0]], (64, 64))
39-
numpy2stl(A, "OUT_.stl", scale=0.05, mask_val=3., ascii=False)
40-
os.path.exists("OUT_.stl")
41-
42-
os.remove("OUT_.stl")
40+
numpy2stl(A, output_name, scale=0.05, mask_val=3., ascii=False)
41+
assert os.path.exists(output_name)
42+
assert os.stat(output_name).st_size > 200000
43+
os.remove(output_name)
4344

4445
if __name__ == '__main__':
4546
unittest.main()

0 commit comments

Comments
 (0)