Commit 9faf6df1 authored by Josef Brandt's avatar Josef Brandt

Critical fix in unittests

Fixes, that the actual tests were not run when using the
parent 8020cfd2
......@@ -206,6 +206,7 @@ class SampleView(QtWidgets.QGraphicsView):
Adds a new handler to the logger to create a log also in the dataset directory
if self.dataset.path != '':
logPath = os.path.join(self.dataset.path, 'gepardLog.txt')'creating new log handler to path: {logPath}')
......@@ -100,7 +100,6 @@ def getShortestPath(_points: np.ndarray) -> List[int]:
:param _points: (N, 2) shape array of x, y coordinates
:returns: list of indices of shortest path to visit all points
numPoints: int = _points.shape[0]
shortestPath: List[int] = list(np.arange(numPoints,
if numPoints >= 4: # the tsp needs at least four points (swap of two pairs of points concurrently)
......@@ -6,6 +6,7 @@ imports work..). Then they have to be added to the allTests-List direclty below.
import unittest
import sys
import inspect
import os
scriptFolder = os.path.realpath(__file__)
gepardParentFolder = os.path.dirname(os.path.dirname(os.path.dirname(scriptFolder))) # three levels up..
......@@ -25,13 +26,18 @@ allTests: list = [TestCoordinateTransform, TestTSP, Test_FakeCamera, TestSimulat
def makeTestSuiteRunnable(suite: unittest.TestSuite):
"""The unittests need a runTest-Method when called this way.
Let's just create a fake one here on the fly.."""
def passMethod():
def makeRunTestLambda(_testCase: unittest.TestCase):
return lambda: runTestStartWith_test_(_testCase)
def runTestStartWith_test_(_testCase: unittest.TestCase):
for methodName, method in inspect.getmembers(_testCase, predicate=inspect.ismethod):
if methodName.startswith("test_"):
for testCase in suite._tests:
runMethod = getattr(testCase, "runTest", None)
if not callable(runMethod):
testCase.runTest = passMethod
testCase.runTest = makeRunTestLambda(testCase)
testSuite: unittest.TestSuite = unittest.TestSuite()
import unittest
import sys
from PyQt5 import QtWidgets
from .testhelpers import getDefaultSampleview
from ..gui.specscanui import SpecScanUI
app: QtWidgets.QApplication = QtWidgets.QApplication(sys.argv)
class TestSpecScanUI(unittest.TestCase):
def setUp(self) -> None:
self.specScanUI: SpecScanUI = SpecScanUI(getDefaultSampleview())
def testLayout(self) -> None:
def test_layout(self) -> None:
\ No newline at end of file
def tearDown(self) -> None:
\ No newline at end of file
......@@ -44,6 +44,12 @@ class TestWorkModes(unittest.TestCase):
def setImageCenter(self, center=None):
def show(self):
def hide(self):
sampleview = self.gepard.view
sampleview.moveStageToPosition = MagicMock()
self.modeHandler.detectMode.widget = FakeDetectViewWidget()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment