diff --git a/sampleview.py b/sampleview.py index 8d66bdcf2f338d74410c508a7038b9584483bf55..5302f98b4e3afb5afc09f276849cea3f36cfdd83 100644 --- a/sampleview.py +++ b/sampleview.py @@ -206,13 +206,14 @@ class SampleView(QtWidgets.QGraphicsView): Adds a new handler to the logger to create a log also in the dataset directory :return: """ - logPath = os.path.join(self.dataset.path, 'gepardLog.txt') - self.logger.info(f'creating new log handler to path: {logPath}') - self.logger.addHandler( - logging.handlers.RotatingFileHandler( - logPath, maxBytes=5 * (1 << 20), backupCount=10) - ) - setDefaultLoggingConfig(self.logger) + if self.dataset.path != '': + logPath = os.path.join(self.dataset.path, 'gepardLog.txt') + self.logger.info(f'creating new log handler to path: {logPath}') + self.logger.addHandler( + logging.handlers.RotatingFileHandler( + logPath, maxBytes=5 * (1 << 20), backupCount=10) + ) + setDefaultLoggingConfig(self.logger) def setupParticleEditor(self): """ diff --git a/specScan.py b/specScan.py index 792cc7e6dcf9019403ea0b00b2d27fae87dff01a..d8bcf785842756a8fba34153763002a4cb9d3c08 100644 --- a/specScan.py +++ b/specScan.py @@ -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 """ - print('SHORTEST PATH HERE') numPoints: int = _points.shape[0] shortestPath: List[int] = list(np.arange(numPoints, dtype=np.int)) if numPoints >= 4: # the tsp needs at least four points (swap of two pairs of points concurrently) diff --git a/unittests/runAllTests.py b/unittests/runAllTests.py index da71052206e86e11f9f47e365dc47aa91d453397..c44b316152cfb7281f6a12095147af2afb679eb5 100644 --- a/unittests/runAllTests.py +++ b/unittests/runAllTests.py @@ -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(): - pass + 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_"): + method() 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() diff --git a/unittests/test_specscanui.py b/unittests/test_specscanui.py index 846e0435a18ecd005410eb460eb49ce7fbd23321..457a8cc15c0e0ddfe1f7409cbd8597bcf9af4584 100644 --- a/unittests/test_specscanui.py +++ b/unittests/test_specscanui.py @@ -1,20 +1,12 @@ 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()) self.specScanUI.view.imparent.hide() - def testLayout(self) -> None: - self.specScanUI.show() - app.exec_() - - def tearDown(self) -> None: - app.closeAllWindows() \ No newline at end of file + def test_layout(self) -> None: + self.specScanUI.show() \ No newline at end of file diff --git a/unittests/test_workModes.py b/unittests/test_workModes.py index bf0a4eb639a1a89c451705d03a2cb17d36ade7f8..369093c1b8abc21894beffb9a03f55bca2a43ba2 100644 --- a/unittests/test_workModes.py +++ b/unittests/test_workModes.py @@ -44,6 +44,12 @@ class TestWorkModes(unittest.TestCase): def setImageCenter(self, center=None): pass + def show(self): + pass + + def hide(self): + pass + sampleview = self.gepard.view sampleview.moveStageToPosition = MagicMock() self.modeHandler.detectMode.widget = FakeDetectViewWidget()