Skip to content
Snippets Groups Projects
Commit cdc61639 authored by jack-parsons's avatar jack-parsons
Browse files

Setting up Gitlab test runner to use unittest script

parent 1567614d
No related branches found
No related tags found
1 merge request!23Merge in Jack's changes
Pipeline #853 passed
sample_job:
script: python tests/sample_test.py
tests:
script: python -m unittest -v
......@@ -5,6 +5,7 @@ Copyright: Joshua Steer 2018, Joshua.Steer@soton.ac.uk
"""
import numpy as np
from numbers import Number
class trimMixin(object):
r"""
......@@ -30,26 +31,26 @@ class trimMixin(object):
>>> amp.planarTrim(100, 2)
"""
# if isinstance(height, float):
if isinstance(height, Number):
# planar values for each vert on face
fv = self.vert[self.faces, plane]
# Number points on each face are above cut plane
fvlogic = (fv > height).sum(axis=1)
# Faces with points both above and below cut plane
adjf = self.faces[np.logical_or(fvlogic == 2, fvlogic == 1)]
# Get adjacent vertices
adjv = np.unique(adjf)
# Get vert above height and set to height
abvInd = adjv[self.vert[adjv, plane] > height]
self.vert[abvInd, plane] = height
# Find all verts above plane
delv = self.vert[:, plane] > height
# Reorder verts to account for deleted one
vInd = np.cumsum(~delv) - 1
self.faces = self.faces[fvlogic != 3, :]
self.faces = vInd[self.faces]
self.vert = self.vert[~delv, :]
self.values = self.values[~delv]
self.calcStruct()
# else:
# raise TypeError("height arg must be a float")
\ No newline at end of file
fv = self.vert[self.faces, plane]
# Number points on each face are above cut plane
fvlogic = (fv > height).sum(axis=1)
# Faces with points both above and below cut plane
adjf = self.faces[np.logical_or(fvlogic == 2, fvlogic == 1)]
# Get adjacent vertices
adjv = np.unique(adjf)
# Get vert above height and set to height
abvInd = adjv[self.vert[adjv, plane] > height]
self.vert[abvInd, plane] = height
# Find all verts above plane
delv = self.vert[:, plane] > height
# Reorder verts to account for deleted one
vInd = np.cumsum(~delv) - 1
self.faces = self.faces[fvlogic != 3, :]
self.faces = vInd[self.faces]
self.vert = self.vert[~delv, :]
self.values = self.values[~delv]
self.calcStruct()
else:
raise TypeError("height arg must be a float")
\ No newline at end of file
from tests import core_tests, basic_tests
import unittest
import core_tests
import basic_tests
def suite():
"""
Get all the unittests for the whole project
:return: The suite containing the test suites for each module
"""
s = unittest.TestSuite()
# Add the tests to the suite
s.addTest(core_tests.suite())
s.addTest(basic_tests.suite())
return s
if __name__ == '__main__':
# Run the test suites
unittest.TextTestRunner().run(suite())
......@@ -6,13 +6,6 @@ import os
import sys
def suite():
"""
Build testing suite from unittests in module
"""
return unittest.TestLoader().loadTestsFromTestCase(TestBasicFunction)
class TestBasicFunction(unittest.TestCase):
def test_setup(self):
......@@ -24,7 +17,6 @@ class TestBasicFunction(unittest.TestCase):
"""
Test that the suite is running correctly
"""
print("Running sample_test.py")
self.assertTrue(True)
def test_python_imports(self):
......
......@@ -8,13 +8,6 @@ import numpy as np
from random import randrange
def suite():
"""
Build testing suite from unittests in module
"""
return unittest.TestLoader().loadTestsFromTestCase(TestCore)
class TestCore(unittest.TestCase):
ACCURACY = 5 # The number of decimal places to value accuracy for - needed due to floating point inaccuracies
......
......@@ -5,13 +5,6 @@ import unittest
import os
def suite():
"""
Build testing suite from unittests in module
"""
return unittest.TestLoader().loadTestsFromTestCase(TestTrim)
class TestTrim(unittest.TestCase):
def setUp(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment