From fef36093994c7c438442857bda4ea6a21becfa8a Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Mon, 7 May 2012 23:17:46 -0600 Subject: [PATCH] moved tests to be submodule of surf --- surf/test/__init__.py | 13 +++++++++++++ surf/test/edge.py | 23 +++++++++++++++++++++++ surf/test/polymesh.py | 26 ++++++++++++++++++++++++++ {test => surf/test}/test00.py | 0 {test => surf/test}/vertex.py | 2 +- test/__init__.py | 0 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 surf/test/__init__.py create mode 100644 surf/test/edge.py create mode 100644 surf/test/polymesh.py rename {test => surf/test}/test00.py (100%) rename {test => surf/test}/vertex.py (97%) delete mode 100644 test/__init__.py diff --git a/surf/test/__init__.py b/surf/test/__init__.py new file mode 100644 index 0000000..e468ca8 --- /dev/null +++ b/surf/test/__init__.py @@ -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__, +] diff --git a/surf/test/edge.py b/surf/test/edge.py new file mode 100644 index 0000000..d4b5069 --- /dev/null +++ b/surf/test/edge.py @@ -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) diff --git a/surf/test/polymesh.py b/surf/test/polymesh.py new file mode 100644 index 0000000..94ea247 --- /dev/null +++ b/surf/test/polymesh.py @@ -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) diff --git a/test/test00.py b/surf/test/test00.py similarity index 100% rename from test/test00.py rename to surf/test/test00.py diff --git a/test/vertex.py b/surf/test/vertex.py similarity index 97% rename from test/vertex.py rename to surf/test/vertex.py index e21cd09..795e85f 100644 --- a/test/vertex.py +++ b/surf/test/vertex.py @@ -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) diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29..0000000