Ability to run all tests at once.

Removed __init__.py

added runTests.py and .sh so that we can run all tests at one time.
This commit is contained in:
Rowan Cockett
2013-07-09 22:00:17 -07:00
parent 8e3e0e0faa
commit 68b4719aea
5 changed files with 22 additions and 13 deletions
-3
View File
@@ -1,3 +0,0 @@
# init.py
from test_mesh import *
+11
View File
@@ -0,0 +1,11 @@
import glob
import unittest
# This code will run all tests in directory named test_*.py
test_file_strings = glob.glob('test_*.py')
module_strings = [str[0:len(str)-3] for str in test_file_strings]
suites = [unittest.defaultTestLoader.loadTestsFromName(str) for str
in module_strings]
testSuite = unittest.TestSuite(suites)
text_runner = unittest.TextTestRunner().run(testSuite)
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
python -m unittest discover
+1 -1
View File
@@ -5,7 +5,7 @@ from BaseMesh import BaseMesh
import numpy as np
class TestMeshNumbers3D(unittest.TestCase):
class TestBaseMesh(unittest.TestCase):
def setUp(self):
self.mesh = BaseMesh([6, 2, 3])
+7 -9
View File
@@ -75,9 +75,15 @@ def mkvc(x, numDims=1):
return x.flatten(order='F')[:, np.newaxis, np.newaxis]
def ndgrid(xin):
def ndgrid(*args):
"""Form tensorial grid for 1, 2 and 3 dimensions. Return X1,X2,X3 arrays depending on the dimension"""
# you can either pass a list [x1, x2, x3] or each seperately
if type(args[0]) == list:
xin = args[0]
else:
xin = args
if len(xin) == 1:
return xin
elif len(xin) == 2:
@@ -88,14 +94,6 @@ def ndgrid(xin):
return np.c_[X1, X2, X3]
def flattenF(x):
return np.flatten(x, order='F')
def printF(x):
pass
def ind2sub(shape, ind):
# From the given shape, returns the subscrips of the given index
revshp = []