moved tests to be submodule of surf

This commit is contained in:
Stephen M. McQuay 2012-05-07 23:17:46 -06:00
parent d117dacf08
commit fef3609399
6 changed files with 63 additions and 1 deletions

13
surf/test/__init__.py Normal file
View File

@ -0,0 +1,13 @@
from .vertex import TestVertex
from .edge import TestEdge
from .polymesh import TestPM
# I only use the convoluted Class.__name__ to pass pyflakes (it complains about
# importing and not using the modules otherwise ...
__all__ = [
TestVertex.__name__,
TestEdge.__name__,
TestPM.__name__,
]

23
surf/test/edge.py Normal file
View File

@ -0,0 +1,23 @@
import unittest
from surf.geometry import Vertex, Edge
class TestEdge(unittest.TestCase):
def setUp(self):
self.origin = Vertex(0, 0, 0)
self.v1 = Vertex(-1, -1, -1)
self.v2 = Vertex(1, 1, 1)
self.v3 = Vertex(5, 4, 3)
self.v4 = Vertex(10, -2, 13)
self.v5 = Vertex(-4, 15.3, 100)
def test_centroid(self):
e = Edge(self.v1, self.v3)
self.assertEqual(e.centroid, Vertex(2, 1.5, 1))
if __name__ == '__main__':
unittest.main(verbosity=3)

26
surf/test/polymesh.py Normal file
View File

@ -0,0 +1,26 @@
import json
import os
import unittest
from surf.geometry import PolygonMesh
class TestPM(unittest.TestCase):
def setUp(self):
path, file_name = os.path.split(__file__)
self.samples_dir = os.path.join(path, os.pardir, os.pardir,
'blender', 'samples')
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
self.cube = json.load(open(self.cube_file_name, 'r'))
def test_cube_load(self):
p = PolygonMesh(**self.cube)
v = p.vertices[0]
self.assertAlmostEqual(v[0], -1.0)
self.assertAlmostEqual(v[1], -1.0)
self.assertAlmostEqual(v[2], -1.0)
if __name__ == '__main__':
unittest.main(verbosity=3)

View File

@ -3,7 +3,7 @@ import unittest
from surf.geometry import Vertex
class TestVertexOperations(unittest.TestCase):
class TestVertex(unittest.TestCase):
def setUp(self):
self.origin = Vertex(0, 0, 0)

View File