-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModuleTests.py
executable file
·91 lines (69 loc) · 2.48 KB
/
ModuleTests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python
# Disable some pylint messages
# pylint: disable=C0103,R0201,W0212,R0904,W0511,W0611
# C0103 : Invalid name "%s" (should match %s)
# W0212 : Access to a protected member %s of a client class
# R0201 : Method could be a function
# R0904 : Too many public methods
# W0511 : TODO/FIXME/XXX
# W0611 : Unused import
"""Quaternions test code
This file performs unit tests for:
Vector (variable-length)
Matrix (variable-dimension)
Quaternion
"""
import unittest
from Vector import Vector, VectorTest
from Matrix import Matrix, MatrixTest
from MathUtil import MathUtil, MathUtilTest
from Quaternion import Quaternion, QuaternionTest
from CoordinateSys import CoordinateSys, CoordinateSysTest
from TriangleGroup import TriangleGroup, TriangleGroupTest
########################################################################
def main():
"""Main routine for Quaternions, intended to be run if the
module is executed on its own."""
runAllUnitTests()
#runUnitTestsFromCase(ModelTest)
########################################################################
# Unit Test Executive Logic
def runAllUnitTests():
'Run all unit tests.'
print "Running all unit tests:"
#unittest.main()
testRunner = unittest.TextTestRunner()
testCases = [VectorTest,
MatrixTest,
QuaternionTest,
CoordinateSysTest,
MathUtilTest,
TriangleGroupTest]
suites = [
unittest.TestLoader().loadTestsFromTestCase(tc)
for tc in testCases ]
suite = suites[0]
if suite is not None:
suite.addTests(suites[1:])
testRunner.run(suite)
def runUnitTestsFromCase(caseClass): # pragma: no cover
"""Run only the unit tests from the specified class, e.g.
runUnitTestsFromCase(QuaternionTest)"""
testRunner = unittest.TextTestRunner()
suite = unittest.TestLoader().loadTestsFromTestCase(caseClass)
if suite != None:
print "Running test suite: " + caseClass.__name__
testRunner.run(suite)
def runVectorTests(): # pragma: no cover
'run vector tests only.'
runUnitTestsFromCase(VectorTest)
def runMatrixTests(): # pragma: no cover
'run matrix tests only.'
runUnitTestsFromCase(MatrixTest)
def runQuaternionTests(): # pragma: no cover
'run quaternion tests only.'
runUnitTestsFromCase(QuaternionTest)
########################################################################
# Main Logic
if __name__ == '__main__':
main()