diff --git a/src/snapred/backend/dao/indexing/CalculationParameters.py b/src/snapred/backend/dao/indexing/CalculationParameters.py index f6c89d0e4..dd2dec0c5 100644 --- a/src/snapred/backend/dao/indexing/CalculationParameters.py +++ b/src/snapred/backend/dao/indexing/CalculationParameters.py @@ -1,6 +1,7 @@ from datetime import datetime from pydantic import field_validator + from snapred.backend.dao.indexing.Versioning import VersionedObject from snapred.backend.dao.state.InstrumentState import InstrumentState diff --git a/src/snapred/backend/dao/indexing/IndexEntry.py b/src/snapred/backend/dao/indexing/IndexEntry.py index 57ec70af3..ced5661b1 100644 --- a/src/snapred/backend/dao/indexing/IndexEntry.py +++ b/src/snapred/backend/dao/indexing/IndexEntry.py @@ -2,6 +2,7 @@ from typing import Any, Optional from pydantic import Field, field_validator, model_validator + from snapred.backend.dao.indexing.Versioning import VersionedObject diff --git a/src/snapred/backend/dao/indexing/Record.py b/src/snapred/backend/dao/indexing/Record.py index b0c580299..50c8f35de 100644 --- a/src/snapred/backend/dao/indexing/Record.py +++ b/src/snapred/backend/dao/indexing/Record.py @@ -1,6 +1,7 @@ from typing import Any from pydantic import ConfigDict, field_validator + from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters from snapred.backend.dao.indexing.Versioning import VersionedObject diff --git a/src/snapred/backend/dao/indexing/Versioning.py b/src/snapred/backend/dao/indexing/Versioning.py index f8da9672b..b29b10463 100644 --- a/src/snapred/backend/dao/indexing/Versioning.py +++ b/src/snapred/backend/dao/indexing/Versioning.py @@ -2,6 +2,7 @@ from numpy import integer from pydantic import BaseModel, computed_field, field_serializer + from snapred.meta.Config import Config VERSION_START = Config["version.start"] diff --git a/src/snapred/ui/view/reduction/ArtificialNormalizationView.py b/src/snapred/ui/view/reduction/ArtificialNormalizationView.py index 3f7732427..21084457a 100644 --- a/src/snapred/ui/view/reduction/ArtificialNormalizationView.py +++ b/src/snapred/ui/view/reduction/ArtificialNormalizationView.py @@ -9,11 +9,12 @@ QMessageBox, QPushButton, ) +from workbench.plotting.figuremanager import MantidFigureCanvas +from workbench.plotting.toolbar import WorkbenchNavigationToolbar + from snapred.meta.Config import Config from snapred.meta.decorators.Resettable import Resettable from snapred.ui.view.BackendRequestView import BackendRequestView -from workbench.plotting.figuremanager import MantidFigureCanvas -from workbench.plotting.toolbar import WorkbenchNavigationToolbar @Resettable diff --git a/src/snapred/ui/view/reduction/ReductionRequestView.py b/src/snapred/ui/view/reduction/ReductionRequestView.py index dac986ad6..fd909dc85 100644 --- a/src/snapred/ui/view/reduction/ReductionRequestView.py +++ b/src/snapred/ui/view/reduction/ReductionRequestView.py @@ -9,6 +9,7 @@ QTextEdit, QVBoxLayout, ) + from snapred.backend.dao.state.RunNumber import RunNumber from snapred.backend.log.logger import snapredLogger from snapred.meta.decorators.Resettable import Resettable diff --git a/src/snapred/ui/view/reduction/ReductionSaveView.py b/src/snapred/ui/view/reduction/ReductionSaveView.py index f1d93b0c7..387a368a1 100644 --- a/src/snapred/ui/view/reduction/ReductionSaveView.py +++ b/src/snapred/ui/view/reduction/ReductionSaveView.py @@ -2,6 +2,7 @@ from qtpy.QtCore import Signal, Slot from qtpy.QtWidgets import QLabel + from snapred.backend.error.ContinueWarning import ContinueWarning from snapred.meta.decorators.Resettable import Resettable from snapred.ui.view.BackendRequestView import BackendRequestView diff --git a/tests/integration/test_controller.py b/tests/integration/test_controller.py index 1bafbedcc..1bf910eec 100644 --- a/tests/integration/test_controller.py +++ b/tests/integration/test_controller.py @@ -1,8 +1,9 @@ import pytest + from snapred.backend.dao.SNAPRequest import SNAPRequest -@pytest.mark.integration() +@pytest.mark.integration def test_executeRequest_noop(): # import must be here or it will put things in a funny state and break other tests from snapred.backend.api.InterfaceController import InterfaceController diff --git a/tests/integration/test_diffcal.py b/tests/integration/test_diffcal.py index 5da0dee26..673e34952 100644 --- a/tests/integration/test_diffcal.py +++ b/tests/integration/test_diffcal.py @@ -3,6 +3,7 @@ import pytest from cis_tests.diffcal_integration_test_script import script as test_script + from snapred.meta.Config import Config, Resource @@ -27,7 +28,7 @@ def _cleanup_directories(): @pytest.mark.golden_data( path=Resource.getPath("outputs/integration/diffcal/golden_data"), short_name="diffcal", date="2024-04-24" ) -@pytest.mark.integration() +@pytest.mark.integration def test_diffcal(goldenData): # to launch, use either of: # * `env=integration_test pytest -m integration`, or diff --git a/tests/integration/test_versions_in_order.py b/tests/integration/test_versions_in_order.py index a593da162..94fffec16 100644 --- a/tests/integration/test_versions_in_order.py +++ b/tests/integration/test_versions_in_order.py @@ -33,6 +33,9 @@ LoadEmptyInstrument, mtd, ) +from util.dao import DAOFactory +from util.diffraction_calibration_synthetic_data import SyntheticData + from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord from snapred.backend.dao.indexing.IndexEntry import IndexEntry from snapred.backend.dao.indexing.Versioning import VERSION_DEFAULT, VERSION_START @@ -48,8 +51,6 @@ from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceType as wngt from snapred.meta.redantic import parse_file_as, write_model_pretty -from util.dao import DAOFactory -from util.diffraction_calibration_synthetic_data import SyntheticData dataSynthesizer = SyntheticData() diff --git a/tests/integration/test_workflow_panels_happy_path.py b/tests/integration/test_workflow_panels_happy_path.py index c77ceb359..c65ba6185 100644 --- a/tests/integration/test_workflow_panels_happy_path.py +++ b/tests/integration/test_workflow_panels_happy_path.py @@ -14,6 +14,7 @@ QMessageBox, QTabWidget, ) +from util.Config_helpers import Config_override # I would prefer not to access `LocalDataService` within an integration test, # however, for the moment, the reduction-data output relocation fixture is defined in the current file. @@ -30,7 +31,6 @@ from snapred.ui.view.NormalizationTweakPeakView import NormalizationTweakPeakView from snapred.ui.view.reduction.ReductionRequestView import ReductionRequestView from snapred.ui.view.reduction.ReductionSaveView import ReductionSaveView -from util.Config_helpers import Config_override # TODO: WorkflowNodeComplete signal, at end of each node! @@ -39,7 +39,7 @@ class InterruptWithBlock(BaseException): pass -@pytest.fixture() +@pytest.fixture def calibration_home_from_mirror(): # Test fixture to create a copy of the calibration home directory from an existing mirror: # * creates a temporary calibration home directory under the optional `prefix` path; @@ -86,7 +86,7 @@ def _calibration_home_from_mirror(prefix: Optional[Path] = None): LocalDataService()._indexer.cache_clear() -@pytest.fixture() +@pytest.fixture def reduction_home_from_mirror(): # Test fixture to write reduction data to a temporary directory under `Config["instrument.reduction.home"]`. # * creates a temporary reduction state root directory under the optional `prefix` path; @@ -135,8 +135,8 @@ def _reduction_home_from_mirror(runNumber: str, prefix: Optional[Path] = None): _stack.close() -@pytest.mark.datarepo() -@pytest.mark.integration() +@pytest.mark.datarepo +@pytest.mark.integration class TestGUIPanels: @pytest.fixture(scope="function", autouse=True) # noqa: PT003 def _setup_gui(self, qapp): diff --git a/tests/unit/backend/dao/test_AllowedPeaks.py b/tests/unit/backend/dao/test_AllowedPeaks.py index a295a9497..ab2fba3e3 100644 --- a/tests/unit/backend/dao/test_AllowedPeaks.py +++ b/tests/unit/backend/dao/test_AllowedPeaks.py @@ -1,5 +1,6 @@ import pytest from pydantic import ValidationError + from snapred.backend.dao.request.CalibrationAssessmentRequest import CalibrationAssessmentRequest from snapred.meta.mantid.AllowedPeakTypes import allowed_peak_type_list from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceName as wngn diff --git a/tests/unit/backend/dao/test_Atom.py b/tests/unit/backend/dao/test_Atom.py index 3d665c717..13e61e0a8 100644 --- a/tests/unit/backend/dao/test_Atom.py +++ b/tests/unit/backend/dao/test_Atom.py @@ -1,5 +1,6 @@ import pytest from pydantic import ValidationError + from snapred.backend.dao.state.CalibrantSample.Atom import Atom diff --git a/tests/unit/backend/dao/test_CalibrantSample.py b/tests/unit/backend/dao/test_CalibrantSample.py index abcc5d0d1..aa719f47d 100644 --- a/tests/unit/backend/dao/test_CalibrantSample.py +++ b/tests/unit/backend/dao/test_CalibrantSample.py @@ -3,9 +3,10 @@ import unittest from mantid.simpleapi import CreateWorkspace, DeleteWorkspace, SetSample -from snapred.backend.dao.state.CalibrantSample.CalibrantSample import CalibrantSample from util.dao import DAOFactory +from snapred.backend.dao.state.CalibrantSample.CalibrantSample import CalibrantSample + class TestCalibrantSample(unittest.TestCase): def setUp(self): diff --git a/tests/unit/backend/dao/test_Crystallography.py b/tests/unit/backend/dao/test_Crystallography.py index be1fe3f88..3b9cb5356 100644 --- a/tests/unit/backend/dao/test_Crystallography.py +++ b/tests/unit/backend/dao/test_Crystallography.py @@ -3,6 +3,7 @@ import pytest from mantid.geometry import CrystalStructure from pydantic import ValidationError + from snapred.backend.dao.state.CalibrantSample.Atom import Atom from snapred.backend.dao.state.CalibrantSample.Crystallography import Crystallography from snapred.meta.Config import Resource diff --git a/tests/unit/backend/dao/test_Geometry.py b/tests/unit/backend/dao/test_Geometry.py index ce3d81501..ecf62e4f9 100644 --- a/tests/unit/backend/dao/test_Geometry.py +++ b/tests/unit/backend/dao/test_Geometry.py @@ -3,6 +3,7 @@ import pytest from mantid.simpleapi import CreateWorkspace, SetSample + from snapred.backend.dao.state.CalibrantSample.Geometry import Geometry diff --git a/tests/unit/backend/dao/test_GroceryListBuilder.py b/tests/unit/backend/dao/test_GroceryListBuilder.py index f8db5e7db..71b9d5d3a 100644 --- a/tests/unit/backend/dao/test_GroceryListBuilder.py +++ b/tests/unit/backend/dao/test_GroceryListBuilder.py @@ -8,6 +8,7 @@ LoadEmptyInstrument, ) from pydantic import ValidationError + from snapred.meta.builder.GroceryListBuilder import GroceryListBuilder from snapred.meta.Config import Resource diff --git a/tests/unit/backend/dao/test_GroceryListItem.py b/tests/unit/backend/dao/test_GroceryListItem.py index 5c3469f54..53eaeb081 100644 --- a/tests/unit/backend/dao/test_GroceryListItem.py +++ b/tests/unit/backend/dao/test_GroceryListItem.py @@ -7,6 +7,7 @@ DeleteWorkspace, LoadEmptyInstrument, ) + from snapred.backend.dao.ingredients.GroceryListItem import GroceryListItem from snapred.meta.builder.GroceryListBuilder import GroceryListBuilder from snapred.meta.Config import Resource diff --git a/tests/unit/backend/dao/test_GroupingMap.py b/tests/unit/backend/dao/test_GroupingMap.py index 9c407bdab..ae4db9f39 100644 --- a/tests/unit/backend/dao/test_GroupingMap.py +++ b/tests/unit/backend/dao/test_GroupingMap.py @@ -4,9 +4,10 @@ # Important: this is a *pure* pytest module: no `unittest` imports should be used. import pytest +from util.groupingMapUtil import GroupingMapTestFactory + from snapred.backend.dao.state import GroupingMap as GroupingMapModule from snapred.meta.Config import Resource -from util.groupingMapUtil import GroupingMapTestFactory GroupingMap = importlib.import_module(GroupingMapModule.__module__) @@ -21,7 +22,7 @@ def _capture_logging(monkeypatch): monkeypatch.setattr(GroupingMap, "logger", defaultLogger) -@pytest.fixture() +@pytest.fixture def groupingMapFactory(): return GroupingMapTestFactory() diff --git a/tests/unit/backend/dao/test_IndexEntry.py b/tests/unit/backend/dao/test_IndexEntry.py index 67b679a8a..01f4c8efb 100644 --- a/tests/unit/backend/dao/test_IndexEntry.py +++ b/tests/unit/backend/dao/test_IndexEntry.py @@ -1,4 +1,5 @@ import pytest + from snapred.backend.dao.indexing.IndexEntry import IndexEntry testData = { diff --git a/tests/unit/backend/dao/test_Material.py b/tests/unit/backend/dao/test_Material.py index dd104615c..940016344 100644 --- a/tests/unit/backend/dao/test_Material.py +++ b/tests/unit/backend/dao/test_Material.py @@ -3,6 +3,7 @@ import pytest from mantid.simpleapi import CreateWorkspace, DeleteWorkspace, SetSample + from snapred.backend.dao.state.CalibrantSample.Material import Material diff --git a/tests/unit/backend/dao/test_PixelGroup.py b/tests/unit/backend/dao/test_PixelGroup.py index d4cf69866..6ddbcbf1d 100644 --- a/tests/unit/backend/dao/test_PixelGroup.py +++ b/tests/unit/backend/dao/test_PixelGroup.py @@ -3,6 +3,7 @@ import unittest import pytest + from snapred.backend.dao.Limit import BinnedValue, Limit from snapred.backend.dao.state.FocusGroup import FocusGroup from snapred.backend.dao.state.PixelGroup import PixelGroup diff --git a/tests/unit/backend/dao/test_RenameWorkspacesFromTemplateRequest.py b/tests/unit/backend/dao/test_RenameWorkspacesFromTemplateRequest.py index 108533c9f..c43603f70 100644 --- a/tests/unit/backend/dao/test_RenameWorkspacesFromTemplateRequest.py +++ b/tests/unit/backend/dao/test_RenameWorkspacesFromTemplateRequest.py @@ -1,5 +1,6 @@ import pytest from pydantic import ValidationError + from snapred.backend.dao.request import RenameWorkspacesFromTemplateRequest diff --git a/tests/unit/backend/dao/test_SNAPResponse.py b/tests/unit/backend/dao/test_SNAPResponse.py index 0b80f279e..0b3f35a18 100644 --- a/tests/unit/backend/dao/test_SNAPResponse.py +++ b/tests/unit/backend/dao/test_SNAPResponse.py @@ -1,5 +1,6 @@ import pytest from pydantic import ValidationError + from snapred.backend.dao.SNAPResponse import ResponseCode, SNAPResponse diff --git a/tests/unit/backend/dao/test_VersionedObject.py b/tests/unit/backend/dao/test_VersionedObject.py index 99b96c761..ded21ea95 100644 --- a/tests/unit/backend/dao/test_VersionedObject.py +++ b/tests/unit/backend/dao/test_VersionedObject.py @@ -4,6 +4,7 @@ import pytest from numpy import int64 + from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters from snapred.backend.dao.indexing.IndexEntry import IndexEntry from snapred.backend.dao.indexing.Record import Record diff --git a/tests/unit/backend/dao/test_WorkspaceMetadata.py b/tests/unit/backend/dao/test_WorkspaceMetadata.py index df6f14ac2..0276a9e6c 100644 --- a/tests/unit/backend/dao/test_WorkspaceMetadata.py +++ b/tests/unit/backend/dao/test_WorkspaceMetadata.py @@ -1,5 +1,6 @@ import pytest from pydantic import ValidationError + from snapred.backend.dao.WorkspaceMetadata import ( UNSET, DiffcalStateMetadata, diff --git a/tests/unit/backend/data/test_DataFactoryService.py b/tests/unit/backend/data/test_DataFactoryService.py index a25e67452..4104325cc 100644 --- a/tests/unit/backend/data/test_DataFactoryService.py +++ b/tests/unit/backend/data/test_DataFactoryService.py @@ -5,6 +5,7 @@ from random import randint from mantid.simpleapi import CreateSingleValuedWorkspace, DeleteWorkspace, mtd + from snapred.backend.dao.calibration import Calibration from snapred.backend.dao.InstrumentConfig import InstrumentConfig from snapred.backend.dao.ReductionState import ReductionState diff --git a/tests/unit/backend/data/test_GroceryService.py b/tests/unit/backend/data/test_GroceryService.py index b011fed44..0d3430134 100644 --- a/tests/unit/backend/data/test_GroceryService.py +++ b/tests/unit/backend/data/test_GroceryService.py @@ -9,7 +9,6 @@ from unittest import mock import pytest -import snapred.backend.recipe.algorithm # noqa: F401 from mantid.dataobjects import MaskWorkspace from mantid.kernel import V3D, Quat from mantid.simpleapi import ( @@ -26,6 +25,13 @@ mtd, ) from mantid.testing import assert_almost_equal as assert_wksp_almost_equal +from util.helpers import createCompatibleDiffCalTable, createCompatibleMask +from util.instrument_helpers import mapFromSampleLogs +from util.kernel_helpers import tupleFromQuat, tupleFromV3D +from util.state_helpers import reduction_root_redirect, state_root_redirect +from util.WhateversInTheFridge import WhateversInTheFridge + +import snapred.backend.recipe.algorithm # noqa: F401 from snapred.backend.dao.ingredients.GroceryListItem import GroceryListItem from snapred.backend.dao.state import DetectorState from snapred.backend.dao.WorkspaceMetadata import UNSET, DiffcalStateMetadata, WorkspaceMetadata @@ -34,11 +40,6 @@ from snapred.meta.mantid.WorkspaceNameGenerator import ValueFormatter as wnvf from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceType -from util.helpers import createCompatibleDiffCalTable, createCompatibleMask -from util.instrument_helpers import mapFromSampleLogs -from util.kernel_helpers import tupleFromQuat, tupleFromV3D -from util.state_helpers import reduction_root_redirect, state_root_redirect -from util.WhateversInTheFridge import WhateversInTheFridge ThisService = "snapred.backend.data.GroceryService." diff --git a/tests/unit/backend/data/test_Indexer.py b/tests/unit/backend/data/test_Indexer.py index 0ea1717d1..51071ef57 100644 --- a/tests/unit/backend/data/test_Indexer.py +++ b/tests/unit/backend/data/test_Indexer.py @@ -11,6 +11,8 @@ import pytest from pydantic import ValidationError +from util.dao import DAOFactory + from snapred.backend.dao.calibration.Calibration import Calibration from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters @@ -23,7 +25,6 @@ from snapred.meta.Config import Resource from snapred.meta.mantid.WorkspaceNameGenerator import ValueFormatter as wnvf from snapred.meta.redantic import parse_file_as, write_model_list_pretty, write_model_pretty -from util.dao import DAOFactory IndexerModule = importlib.import_module(Indexer.__module__) diff --git a/tests/unit/backend/data/test_LocalDataService.py b/tests/unit/backend/data/test_LocalDataService.py index d74adaff4..2351facae 100644 --- a/tests/unit/backend/data/test_LocalDataService.py +++ b/tests/unit/backend/data/test_LocalDataService.py @@ -34,6 +34,12 @@ SaveDiffCal, mtd, ) +from util.Config_helpers import Config_override +from util.dao import DAOFactory +from util.helpers import createCompatibleDiffCalTable, createCompatibleMask +from util.instrument_helpers import addInstrumentLogs, getInstrumentLogDescriptors +from util.state_helpers import reduction_root_redirect, state_root_redirect + from snapred.backend.dao import StateConfig from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord from snapred.backend.dao.GroupPeakList import GroupPeakList @@ -68,11 +74,6 @@ WorkspaceType as wngt, ) from snapred.meta.redantic import parse_file_as, write_model_pretty -from util.Config_helpers import Config_override -from util.dao import DAOFactory -from util.helpers import createCompatibleDiffCalTable, createCompatibleMask -from util.instrument_helpers import addInstrumentLogs, getInstrumentLogDescriptors -from util.state_helpers import reduction_root_redirect, state_root_redirect LocalDataServiceModule = importlib.import_module(LocalDataService.__module__) ThisService = "snapred.backend.data.LocalDataService." @@ -1500,7 +1501,7 @@ def test_readWriteReductionRecord(): assert actualRecord == testRecord -@pytest.fixture() +@pytest.fixture def readSyntheticReductionRecord(): # Read a `ReductionRecord` from the specified file path: # * update the record's timestamp and workspace-name list using the specified value. @@ -1554,7 +1555,7 @@ def _readSyntheticReductionRecord(filePath: Path, timestamp: float) -> Reduction pass -@pytest.fixture() +@pytest.fixture def createReductionWorkspaces(cleanup_workspace_at_exit): # Create sample workspaces from a list of names: # * these workspaces are automatically deleted at teardown. @@ -2007,7 +2008,7 @@ def test_readDetectorState_bad_logs(): localDataService.readDetectorState("123") -@pytest.fixture() +@pytest.fixture def instrumentWorkspace(cleanup_workspace_at_exit): useLiteMode = True wsName = mtd.unique_hidden_name() diff --git a/tests/unit/backend/data/test_NexusHDF5Metadata.py b/tests/unit/backend/data/test_NexusHDF5Metadata.py index 94402ad52..3dab35a18 100644 --- a/tests/unit/backend/data/test_NexusHDF5Metadata.py +++ b/tests/unit/backend/data/test_NexusHDF5Metadata.py @@ -4,9 +4,10 @@ from pathlib import Path import h5py +from util.script_as_test import not_a_test + from snapred.backend.data.NexusHDF5Metadata import NexusHDF5Metadata as n5m from snapred.meta.Config import Resource -from util.script_as_test import not_a_test # IMPLEMENTATION NOTES: # * The following reference was very useful during the design of this implementation diff --git a/tests/unit/backend/log/test_progress.py b/tests/unit/backend/log/test_progress.py index f541cd1e5..0b8869fb8 100644 --- a/tests/unit/backend/log/test_progress.py +++ b/tests/unit/backend/log/test_progress.py @@ -2,6 +2,7 @@ from unittest.mock import MagicMock from mantid.api import Progress + from snapred.backend.log.logger import snapredLogger diff --git a/tests/unit/backend/recipe/algorithm/test_CalculateDiffCalTable.py b/tests/unit/backend/recipe/algorithm/test_CalculateDiffCalTable.py index d7cd6dfce..389a53558 100644 --- a/tests/unit/backend/recipe/algorithm/test_CalculateDiffCalTable.py +++ b/tests/unit/backend/recipe/algorithm/test_CalculateDiffCalTable.py @@ -5,6 +5,7 @@ DeleteWorkspace, mtd, ) + from snapred.meta.Config import Resource diff --git a/tests/unit/backend/recipe/algorithm/test_CalibrationMetricExtractionAlgorithm.py b/tests/unit/backend/recipe/algorithm/test_CalibrationMetricExtractionAlgorithm.py index 8fb4fc8bb..3eda3d8e9 100644 --- a/tests/unit/backend/recipe/algorithm/test_CalibrationMetricExtractionAlgorithm.py +++ b/tests/unit/backend/recipe/algorithm/test_CalibrationMetricExtractionAlgorithm.py @@ -8,6 +8,7 @@ import pytest from mantid.api import WorkspaceGroup from mantid.simpleapi import CreateSingleValuedWorkspace, CreateWorkspace, GenerateTableWorkspaceFromListOfDict, mtd + from snapred.backend.dao.calibration.CalibrationMetric import CalibrationMetric from snapred.backend.dao.state import PixelGroup, PixelGroupingParameters from snapred.backend.recipe.algorithm.CalibrationMetricExtractionAlgorithm import ( diff --git a/tests/unit/backend/recipe/algorithm/test_ConjoinDiagnosticWorkspaces.py b/tests/unit/backend/recipe/algorithm/test_ConjoinDiagnosticWorkspaces.py index 4ee55172a..6c9e9ca5a 100644 --- a/tests/unit/backend/recipe/algorithm/test_ConjoinDiagnosticWorkspaces.py +++ b/tests/unit/backend/recipe/algorithm/test_ConjoinDiagnosticWorkspaces.py @@ -12,14 +12,14 @@ mtd, ) from mantid.testing import assert_almost_equal +from util.diffraction_calibration_synthetic_data import SyntheticData +from util.helpers import deleteWorkspaceNoThrow # the algorithm to test from snapred.backend.recipe.algorithm.ConjoinDiagnosticWorkspaces import ( ConjoinDiagnosticWorkspaces as Algo, # noqa: E402 ) from snapred.meta.pointer import create_pointer -from util.diffraction_calibration_synthetic_data import SyntheticData -from util.helpers import deleteWorkspaceNoThrow class TestConjoinDiagnosticWorkspaces(unittest.TestCase): diff --git a/tests/unit/backend/recipe/algorithm/test_CreateArtificialNormalizationAlgo.py b/tests/unit/backend/recipe/algorithm/test_CreateArtificialNormalizationAlgo.py index 817d8ab1d..7f9aa80ca 100644 --- a/tests/unit/backend/recipe/algorithm/test_CreateArtificialNormalizationAlgo.py +++ b/tests/unit/backend/recipe/algorithm/test_CreateArtificialNormalizationAlgo.py @@ -5,9 +5,10 @@ ConvertUnits, mtd, ) +from util.diffraction_calibration_synthetic_data import SyntheticData + from snapred.backend.dao.ingredients.ArtificialNormalizationIngredients import ArtificialNormalizationIngredients from snapred.backend.recipe.algorithm.CreateArtificialNormalizationAlgo import CreateArtificialNormalizationAlgo as Algo -from util.diffraction_calibration_synthetic_data import SyntheticData class TestCreateArtificialNormalizationAlgo(unittest.TestCase): diff --git a/tests/unit/backend/recipe/algorithm/test_DetectorPeakPredictor.py b/tests/unit/backend/recipe/algorithm/test_DetectorPeakPredictor.py index d9368e807..f8a952358 100644 --- a/tests/unit/backend/recipe/algorithm/test_DetectorPeakPredictor.py +++ b/tests/unit/backend/recipe/algorithm/test_DetectorPeakPredictor.py @@ -14,6 +14,7 @@ }, ): from mantid.simpleapi import DeleteWorkspace, mtd + from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.recipe.algorithm.DetectorPeakPredictor import DetectorPeakPredictor from snapred.meta.Config import Resource diff --git a/tests/unit/backend/recipe/algorithm/test_DiffractionSpectrumWeightCalculator.py b/tests/unit/backend/recipe/algorithm/test_DiffractionSpectrumWeightCalculator.py index 045f4f9a2..d1935791c 100644 --- a/tests/unit/backend/recipe/algorithm/test_DiffractionSpectrumWeightCalculator.py +++ b/tests/unit/backend/recipe/algorithm/test_DiffractionSpectrumWeightCalculator.py @@ -3,9 +3,10 @@ import pytest from mantid.testing import assert_almost_equal +from util.diffraction_calibration_synthetic_data import SyntheticData + from snapred.backend.dao import CrystallographicPeak, DetectorPeak, GroupPeakList from snapred.meta.redantic import list_to_raw -from util.diffraction_calibration_synthetic_data import SyntheticData with mock.patch.dict( "sys.modules", diff --git a/tests/unit/backend/recipe/algorithm/test_FitMultiplePeaksAlgorithm.py b/tests/unit/backend/recipe/algorithm/test_FitMultiplePeaksAlgorithm.py index 73c7987c4..2204bb5cb 100644 --- a/tests/unit/backend/recipe/algorithm/test_FitMultiplePeaksAlgorithm.py +++ b/tests/unit/backend/recipe/algorithm/test_FitMultiplePeaksAlgorithm.py @@ -3,6 +3,7 @@ from typing import List import pydantic + from snapred.backend.dao.request.FarmFreshIngredients import FarmFreshIngredients from snapred.meta.mantid.FitPeaksOutput import FIT_PEAK_DIAG_SUFFIX @@ -14,13 +15,14 @@ }, ): from mantid.simpleapi import CreateSingleValuedWorkspace, CreateWorkspace, LoadNexusProcessed, mtd + from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.recipe.algorithm.FitMultiplePeaksAlgorithm import ( FitMultiplePeaksAlgorithm, # noqa: E402 ) from snapred.meta.Config import Resource from snapred.meta.redantic import list_to_raw - from util.SculleryBoy import SculleryBoy def test_init(): """Test ability to initialize fit multiple peaks algo""" diff --git a/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py b/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py index 3d7b19fae..850e71da6 100644 --- a/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py +++ b/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py @@ -5,13 +5,13 @@ mtd, ) from mantid.testing import assert_almost_equal +from util.dao import DAOFactory # the algorithm to test from snapred.backend.recipe.algorithm.FocusSpectraAlgorithm import ( FocusSpectraAlgorithm as ThisAlgo, # noqa: E402 ) from snapred.meta.Config import Resource -from util.dao import DAOFactory class TestFocusSpectra(unittest.TestCase): diff --git a/tests/unit/backend/recipe/algorithm/test_GroupedDetectorIDs.py b/tests/unit/backend/recipe/algorithm/test_GroupedDetectorIDs.py index e5c0e350b..d6265559c 100644 --- a/tests/unit/backend/recipe/algorithm/test_GroupedDetectorIDs.py +++ b/tests/unit/backend/recipe/algorithm/test_GroupedDetectorIDs.py @@ -4,10 +4,11 @@ CreateSingleValuedWorkspace, mtd, ) +from util.diffraction_calibration_synthetic_data import SyntheticData + from snapred.backend.recipe.algorithm.GroupedDetectorIDs import GroupedDetectorIDs as Algo from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.meta.pointer import access_pointer -from util.diffraction_calibration_synthetic_data import SyntheticData class TestGroupedDetectorIDs(unittest.TestCase): diff --git a/tests/unit/backend/recipe/algorithm/test_LiteDataCreationAlgo.py b/tests/unit/backend/recipe/algorithm/test_LiteDataCreationAlgo.py index 494d75032..e2623a37d 100644 --- a/tests/unit/backend/recipe/algorithm/test_LiteDataCreationAlgo.py +++ b/tests/unit/backend/recipe/algorithm/test_LiteDataCreationAlgo.py @@ -3,9 +3,10 @@ import pytest from mantid.simpleapi import DeleteWorkspace, mtd +from util.dao import DAOFactory + from snapred.backend.recipe.algorithm.LiteDataCreationAlgo import LiteDataCreationAlgo from snapred.meta.Config import Resource -from util.dao import DAOFactory HAVE_MOUNT_SNAP = os.path.exists("/SNS/SNAP/") diff --git a/tests/unit/backend/recipe/algorithm/test_LoadGroupingDefinition.py b/tests/unit/backend/recipe/algorithm/test_LoadGroupingDefinition.py index a9ae6964b..82bc618da 100644 --- a/tests/unit/backend/recipe/algorithm/test_LoadGroupingDefinition.py +++ b/tests/unit/backend/recipe/algorithm/test_LoadGroupingDefinition.py @@ -12,6 +12,7 @@ mtd, ) from mantid.testing import assert_almost_equal as assert_wksp_almost_equal + from snapred.backend.recipe.algorithm.LoadGroupingDefinition import LoadGroupingDefinition as LoadingAlgo from snapred.meta.Config import Resource diff --git a/tests/unit/backend/recipe/algorithm/test_MantidSnapper.py b/tests/unit/backend/recipe/algorithm/test_MantidSnapper.py index 62033fd18..6ba7f7010 100644 --- a/tests/unit/backend/recipe/algorithm/test_MantidSnapper.py +++ b/tests/unit/backend/recipe/algorithm/test_MantidSnapper.py @@ -2,6 +2,7 @@ from unittest import mock from mantid.kernel import Direction + from snapred.backend.recipe.algorithm.MantidSnapper import MantidSnapper from snapred.meta.Callback import callback diff --git a/tests/unit/backend/recipe/algorithm/test_MaskDetectorFlags.py b/tests/unit/backend/recipe/algorithm/test_MaskDetectorFlags.py index 63b216e7d..88cbc29dc 100644 --- a/tests/unit/backend/recipe/algorithm/test_MaskDetectorFlags.py +++ b/tests/unit/backend/recipe/algorithm/test_MaskDetectorFlags.py @@ -5,15 +5,16 @@ mtd, ) from mantid.testing import assert_almost_equal +from util.helpers import ( + createCompatibleMask, + deleteWorkspaceNoThrow, +) + from snapred.backend.log.logger import snapredLogger # the algorithm to test from snapred.backend.recipe.algorithm.MaskDetectorFlags import MaskDetectorFlags from snapred.meta.Config import Resource -from util.helpers import ( - createCompatibleMask, - deleteWorkspaceNoThrow, -) logger = snapredLogger.getLogger(__name__) diff --git a/tests/unit/backend/recipe/algorithm/test_OffsetStatistics.py b/tests/unit/backend/recipe/algorithm/test_OffsetStatistics.py index a4ab93823..65fd67e1b 100644 --- a/tests/unit/backend/recipe/algorithm/test_OffsetStatistics.py +++ b/tests/unit/backend/recipe/algorithm/test_OffsetStatistics.py @@ -7,6 +7,7 @@ OffsetStatistics, mtd, ) + from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.meta.pointer import access_pointer diff --git a/tests/unit/backend/recipe/algorithm/test_PixelGroupingParametersCalculationAlgorithm.py b/tests/unit/backend/recipe/algorithm/test_PixelGroupingParametersCalculationAlgorithm.py index 714bed254..4083d611e 100644 --- a/tests/unit/backend/recipe/algorithm/test_PixelGroupingParametersCalculationAlgorithm.py +++ b/tests/unit/backend/recipe/algorithm/test_PixelGroupingParametersCalculationAlgorithm.py @@ -17,6 +17,12 @@ RenameWorkspace, mtd, ) +from util.dao import DAOFactory +from util.helpers import ( + createCompatibleMask, + maskComponentByName, +) + from snapred.backend.dao.ingredients.PixelGroupingIngredients import PixelGroupingIngredients from snapred.backend.dao.state.PixelGroupingParameters import PixelGroupingParameters from snapred.backend.data.GroceryService import GroceryService @@ -25,11 +31,6 @@ ) from snapred.meta.Config import Resource from snapred.meta.redantic import write_model_list_pretty -from util.dao import DAOFactory -from util.helpers import ( - createCompatibleMask, - maskComponentByName, -) GENERATE_GOLDEN_DATA = False GOLDEN_DATA_DATE = "2024-05-20" # date.today().isoformat() diff --git a/tests/unit/backend/recipe/algorithm/test_PurgeOverlappingPeaksAlgorithm.py b/tests/unit/backend/recipe/algorithm/test_PurgeOverlappingPeaksAlgorithm.py index 67244786b..f3bff668f 100644 --- a/tests/unit/backend/recipe/algorithm/test_PurgeOverlappingPeaksAlgorithm.py +++ b/tests/unit/backend/recipe/algorithm/test_PurgeOverlappingPeaksAlgorithm.py @@ -1,9 +1,10 @@ import unittest.mock as mock -from snapred.backend.dao import GroupPeakList from util.dao import DAOFactory from util.diffraction_calibration_synthetic_data import SyntheticData +from snapred.backend.dao import GroupPeakList + with mock.patch.dict( "sys.modules", { diff --git a/tests/unit/backend/recipe/algorithm/test_RawVanadiumCorrection.py b/tests/unit/backend/recipe/algorithm/test_RawVanadiumCorrection.py index 80e68e2c7..20444234b 100644 --- a/tests/unit/backend/recipe/algorithm/test_RawVanadiumCorrection.py +++ b/tests/unit/backend/recipe/algorithm/test_RawVanadiumCorrection.py @@ -13,6 +13,7 @@ mtd, ) from numpy import argmax +from util.SculleryBoy import SculleryBoy # needed to make mocked ingredients # the algorithm to test @@ -20,7 +21,6 @@ RawVanadiumCorrectionAlgorithm as Algo, # noqa: E402 ) from snapred.meta.Config import Resource -from util.SculleryBoy import SculleryBoy class TestRawVanadiumCorrection(unittest.TestCase): diff --git a/tests/unit/backend/recipe/algorithm/test_RemoveEventBackground.py b/tests/unit/backend/recipe/algorithm/test_RemoveEventBackground.py index 24bec24c0..68dcbebd3 100644 --- a/tests/unit/backend/recipe/algorithm/test_RemoveEventBackground.py +++ b/tests/unit/backend/recipe/algorithm/test_RemoveEventBackground.py @@ -4,11 +4,12 @@ ConvertToEventWorkspace, mtd, ) +from util.diffraction_calibration_synthetic_data import SyntheticData + from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.recipe.algorithm.RemoveEventBackground import RemoveEventBackground as Algo from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.meta.pointer import create_pointer -from util.diffraction_calibration_synthetic_data import SyntheticData class TestRemoveEventBackground(unittest.TestCase): diff --git a/tests/unit/backend/recipe/algorithm/test_SaveGroupingDefinition.py b/tests/unit/backend/recipe/algorithm/test_SaveGroupingDefinition.py index 6364ae3dc..5dce7b63a 100644 --- a/tests/unit/backend/recipe/algorithm/test_SaveGroupingDefinition.py +++ b/tests/unit/backend/recipe/algorithm/test_SaveGroupingDefinition.py @@ -17,6 +17,7 @@ mtd, ) from mantid.testing import assert_almost_equal as assert_wksp_almost_equal + from snapred.backend.recipe.algorithm.LoadGroupingDefinition import LoadGroupingDefinition as LoadingAlgo from snapred.backend.recipe.algorithm.SaveGroupingDefinition import SaveGroupingDefinition as SavingAlgo from snapred.meta.Config import Resource diff --git a/tests/unit/backend/recipe/algorithm/test_SmoothDataExcludingPeaksAlgo.py b/tests/unit/backend/recipe/algorithm/test_SmoothDataExcludingPeaksAlgo.py index 80490fb7b..76f982065 100644 --- a/tests/unit/backend/recipe/algorithm/test_SmoothDataExcludingPeaksAlgo.py +++ b/tests/unit/backend/recipe/algorithm/test_SmoothDataExcludingPeaksAlgo.py @@ -7,11 +7,12 @@ LoadNexusProcessed, mtd, ) +from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.request import FarmFreshIngredients from snapred.backend.recipe.algorithm.SmoothDataExcludingPeaksAlgo import SmoothDataExcludingPeaksAlgo as Algo from snapred.meta.Config import Resource from snapred.meta.redantic import list_to_raw -from util.SculleryBoy import SculleryBoy class TestSmoothDataAlgo(unittest.TestCase): diff --git a/tests/unit/backend/recipe/test_ApplyNormalizationRecipe.py b/tests/unit/backend/recipe/test_ApplyNormalizationRecipe.py index 96d466502..bea9c20fa 100644 --- a/tests/unit/backend/recipe/test_ApplyNormalizationRecipe.py +++ b/tests/unit/backend/recipe/test_ApplyNormalizationRecipe.py @@ -2,11 +2,12 @@ import pytest from mantid.simpleapi import CreateSingleValuedWorkspace, mtd +from util.Config_helpers import Config_override +from util.SculleryBoy import SculleryBoy + from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.backend.recipe.ApplyNormalizationRecipe import ApplyNormalizationRecipe, Ingredients from snapred.meta.Config import Config -from util.Config_helpers import Config_override -from util.SculleryBoy import SculleryBoy class ApplyNormalizationRecipeTest(unittest.TestCase): diff --git a/tests/unit/backend/recipe/test_DiffractionCalibrationRecipe.py b/tests/unit/backend/recipe/test_DiffractionCalibrationRecipe.py index 1dfed7373..fe8d0a89e 100644 --- a/tests/unit/backend/recipe/test_DiffractionCalibrationRecipe.py +++ b/tests/unit/backend/recipe/test_DiffractionCalibrationRecipe.py @@ -3,11 +3,12 @@ import pytest from mantid.simpleapi import mtd -from snapred.backend.dao.request.SimpleDiffCalRequest import SimpleDiffCalRequest -from snapred.backend.service.CalibrationService import CalibrationService from util.diffraction_calibration_synthetic_data import SyntheticData from util.helpers import deleteWorkspaceNoThrow +from snapred.backend.dao.request.SimpleDiffCalRequest import SimpleDiffCalRequest +from snapred.backend.service.CalibrationService import CalibrationService + ThisService: str = "snapred.backend.service.CalibrationService" PixelCalRx: str = ThisService + ".PixelDiffCalRecipe" GroupCalRx: str = ThisService + ".GroupDiffCalRecipe" diff --git a/tests/unit/backend/recipe/test_FetchGroceriesRecipe.py b/tests/unit/backend/recipe/test_FetchGroceriesRecipe.py index 66efa0a0b..cbc2591ee 100644 --- a/tests/unit/backend/recipe/test_FetchGroceriesRecipe.py +++ b/tests/unit/backend/recipe/test_FetchGroceriesRecipe.py @@ -12,6 +12,7 @@ mtd, ) from mantid.testing import assert_almost_equal as assert_wksp_almost_equal + from snapred.backend.dao.ingredients.GroceryListItem import GroceryListItem # needed to make mocked ingredients diff --git a/tests/unit/backend/recipe/test_GenerateFocussedVanadiumRecipe.py b/tests/unit/backend/recipe/test_GenerateFocussedVanadiumRecipe.py index a96cd2fd1..6cb5a3934 100644 --- a/tests/unit/backend/recipe/test_GenerateFocussedVanadiumRecipe.py +++ b/tests/unit/backend/recipe/test_GenerateFocussedVanadiumRecipe.py @@ -6,12 +6,13 @@ LoadNexusProcessed, mtd, ) +from util.helpers import deleteWorkspaceNoThrow +from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.ingredients import GenerateFocussedVanadiumIngredients as Ingredients from snapred.backend.dao.request import FarmFreshIngredients from snapred.backend.recipe.GenerateFocussedVanadiumRecipe import GenerateFocussedVanadiumRecipe as Recipe from snapred.meta.Config import Resource -from util.helpers import deleteWorkspaceNoThrow -from util.SculleryBoy import SculleryBoy ThisRecipe: str = "snapred.backend.recipe.GenerateFocussedVanadiumRecipe" diff --git a/tests/unit/backend/recipe/test_GenericRecipe.py b/tests/unit/backend/recipe/test_GenericRecipe.py index f4de30f51..5d6affa5a 100644 --- a/tests/unit/backend/recipe/test_GenericRecipe.py +++ b/tests/unit/backend/recipe/test_GenericRecipe.py @@ -10,6 +10,7 @@ from mantid.simpleapi import CloneWorkspace, CreateSingleValuedWorkspace from mantid.testing import assert_almost_equal as assert_wksp_almost_equal from pydantic import BaseModel + from snapred.backend.dao.ingredients import ReductionIngredients from snapred.backend.error.AlgorithmException import AlgorithmException from snapred.backend.recipe.GenericRecipe import GenericRecipe diff --git a/tests/unit/backend/recipe/test_GroupDiffCalRecipe.py b/tests/unit/backend/recipe/test_GroupDiffCalRecipe.py index a0dcbffc7..d0eddf3d7 100644 --- a/tests/unit/backend/recipe/test_GroupDiffCalRecipe.py +++ b/tests/unit/backend/recipe/test_GroupDiffCalRecipe.py @@ -6,6 +6,8 @@ from mantid.api import MatrixWorkspace from mantid.dataobjects import GroupingWorkspace from mantid.simpleapi import CalculateDiffCalTable, mtd +from util.diffraction_calibration_synthetic_data import SyntheticData +from util.helpers import deleteWorkspaceNoThrow, maskGroups, mutableWorkspaceClones, setGroupSpectraToZero # needed to make mocked ingredients from snapred.backend.log.logger import snapredLogger @@ -14,8 +16,6 @@ from snapred.backend.recipe.GroupDiffCalRecipe import ( GroupDiffCalRecipe as Recipe, # noqa: E402 ) -from util.diffraction_calibration_synthetic_data import SyntheticData -from util.helpers import deleteWorkspaceNoThrow, maskGroups, mutableWorkspaceClones, setGroupSpectraToZero logger = snapredLogger.getLogger(__name__) diff --git a/tests/unit/backend/recipe/test_PixelDiffCalRecipe.py b/tests/unit/backend/recipe/test_PixelDiffCalRecipe.py index 68a11fc8d..761395a0c 100644 --- a/tests/unit/backend/recipe/test_PixelDiffCalRecipe.py +++ b/tests/unit/backend/recipe/test_PixelDiffCalRecipe.py @@ -5,13 +5,13 @@ from mantid.api import MatrixWorkspace from mantid.simpleapi import mtd +from util.diffraction_calibration_synthetic_data import SyntheticData +from util.helpers import maskSpectra, setSpectraToZero # needed to make mocked ingredients # the algorithm to test from snapred.backend.recipe.PixelDiffCalRecipe import PixelDiffCalRecipe as Recipe from snapred.meta.Config import Config -from util.diffraction_calibration_synthetic_data import SyntheticData -from util.helpers import maskSpectra, setSpectraToZero """ NOTE this is in fact a test of a recipe. Its location and name are a diff --git a/tests/unit/backend/recipe/test_PixelGroupingParametersCalculationRecipe.py b/tests/unit/backend/recipe/test_PixelGroupingParametersCalculationRecipe.py index 3c93bdf22..329c530c6 100644 --- a/tests/unit/backend/recipe/test_PixelGroupingParametersCalculationRecipe.py +++ b/tests/unit/backend/recipe/test_PixelGroupingParametersCalculationRecipe.py @@ -1,6 +1,7 @@ import unittest.mock as mock import pytest + from snapred.backend.dao.Limit import Limit from snapred.backend.dao.state.PixelGroupingParameters import PixelGroupingParameters from snapred.backend.recipe.PixelGroupingParametersCalculationRecipe import PixelGroupingParametersCalculationRecipe diff --git a/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py b/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py index 08f97c4be..d5866b4d6 100644 --- a/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py +++ b/tests/unit/backend/recipe/test_PreprocessReductionRecipe.py @@ -6,11 +6,12 @@ LoadInstrument, mtd, ) +from util.helpers import createCompatibleMask +from util.SculleryBoy import SculleryBoy + from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.backend.recipe.PreprocessReductionRecipe import Ingredients, PreprocessReductionRecipe from snapred.meta.Config import Resource -from util.helpers import createCompatibleMask -from util.SculleryBoy import SculleryBoy class PreprocessReductionRecipeTest(unittest.TestCase): diff --git a/tests/unit/backend/recipe/test_ReadWorkspaceMetadata.py b/tests/unit/backend/recipe/test_ReadWorkspaceMetadata.py index 9fc38380c..480b7f6ee 100644 --- a/tests/unit/backend/recipe/test_ReadWorkspaceMetadata.py +++ b/tests/unit/backend/recipe/test_ReadWorkspaceMetadata.py @@ -12,12 +12,12 @@ # mantid imports from mantid.simpleapi import AddSampleLogMultiple, CreateSingleValuedWorkspace, mtd from pydantic import BaseModel, ConfigDict, ValidationError +from util.helpers import deleteWorkspaceNoThrow # the algorithm to test from snapred.backend.dao.WorkspaceMetadata import UNSET from snapred.backend.recipe.ReadWorkspaceMetadata import ReadWorkspaceMetadata from snapred.meta.Config import Config -from util.helpers import deleteWorkspaceNoThrow thisRecipe = "snapred.backend.recipe.ReadWorkspaceMetadata." TAG_PREFIX = Config["metadata.tagPrefix"] diff --git a/tests/unit/backend/recipe/test_Recipe.py b/tests/unit/backend/recipe/test_Recipe.py index 2d58b481f..7e00bbd91 100644 --- a/tests/unit/backend/recipe/test_Recipe.py +++ b/tests/unit/backend/recipe/test_Recipe.py @@ -4,10 +4,11 @@ import pytest from mantid.simpleapi import CreateSingleValuedWorkspace, mtd from pydantic import BaseModel, ConfigDict +from util.SculleryBoy import SculleryBoy + from snapred.backend.recipe.algorithm.Utensils import Utensils from snapred.backend.recipe.Recipe import Recipe from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceName -from util.SculleryBoy import SculleryBoy class Ingredients(BaseModel): diff --git a/tests/unit/backend/recipe/test_ReductionRecipe.py b/tests/unit/backend/recipe/test_ReductionRecipe.py index e7f543c6a..6a5b18a89 100644 --- a/tests/unit/backend/recipe/test_ReductionRecipe.py +++ b/tests/unit/backend/recipe/test_ReductionRecipe.py @@ -3,6 +3,8 @@ import pytest from mantid.simpleapi import CreateSingleValuedWorkspace, mtd +from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.ingredients import ReductionIngredients from snapred.backend.recipe.ReductionRecipe import ( ApplyNormalizationRecipe, @@ -12,7 +14,6 @@ ReductionRecipe, ) from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng -from util.SculleryBoy import SculleryBoy class ReductionRecipeTest(TestCase): diff --git a/tests/unit/backend/recipe/test_WriteWorkspaceMetadata.py b/tests/unit/backend/recipe/test_WriteWorkspaceMetadata.py index 201df3bf0..ffd20fc2e 100644 --- a/tests/unit/backend/recipe/test_WriteWorkspaceMetadata.py +++ b/tests/unit/backend/recipe/test_WriteWorkspaceMetadata.py @@ -13,13 +13,13 @@ mtd, ) from pydantic import BaseModel, ConfigDict, ValidationError +from util.helpers import deleteWorkspaceNoThrow # the algorithm to test from snapred.backend.dao.WorkspaceMetadata import UNSET from snapred.backend.recipe.ReadWorkspaceMetadata import ReadWorkspaceMetadata from snapred.backend.recipe.WriteWorkspaceMetadata import WriteWorkspaceMetadata from snapred.meta.Config import Config -from util.helpers import deleteWorkspaceNoThrow thisRecipe = "snapred.backend.recipe.WriteWorkspaceMetadata." readRecipe = "snapred.backend.recipe.ReadWorkspaceMetadata." diff --git a/tests/unit/backend/service/test_CalibrationService.py b/tests/unit/backend/service/test_CalibrationService.py index bac6f2162..83ddb73a3 100644 --- a/tests/unit/backend/service/test_CalibrationService.py +++ b/tests/unit/backend/service/test_CalibrationService.py @@ -20,6 +20,9 @@ LoadInstrument, mtd, ) +from util.dao import DAOFactory +from util.state_helpers import state_root_redirect + from snapred.backend.dao.ingredients import CalibrationMetricsWorkspaceIngredients from snapred.backend.dao.request import ( CalibrationAssessmentRequest, @@ -42,8 +45,6 @@ from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceType as wngt from snapred.meta.redantic import parse_file_as -from util.dao import DAOFactory -from util.state_helpers import state_root_redirect # Mock out of scope modules before importing DataExportService @@ -58,6 +59,12 @@ "snapred.backend.log.logger": mock.Mock(), }, ): + from util.helpers import ( + createCompatibleDiffCalTable, + createCompatibleMask, + ) + from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.calibration.CalibrationMetric import CalibrationMetric from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord from snapred.backend.dao.indexing.IndexEntry import IndexEntry @@ -71,11 +78,6 @@ from snapred.backend.service.CalibrationService import CalibrationService from snapred.backend.service.SousChef import SousChef from snapred.meta.Config import Resource - from util.helpers import ( - createCompatibleDiffCalTable, - createCompatibleMask, - ) - from util.SculleryBoy import SculleryBoy thisService = "snapred.backend.service.CalibrationService." diff --git a/tests/unit/backend/service/test_CrystallographicInfoService.py b/tests/unit/backend/service/test_CrystallographicInfoService.py index 2f94e75d9..f48a2972d 100644 --- a/tests/unit/backend/service/test_CrystallographicInfoService.py +++ b/tests/unit/backend/service/test_CrystallographicInfoService.py @@ -2,6 +2,7 @@ from unittest import mock import pytest + from snapred.backend.service.CrystallographicInfoService import CrystallographicInfoService from snapred.meta.Config import Config diff --git a/tests/unit/backend/service/test_LiteDataService.py b/tests/unit/backend/service/test_LiteDataService.py index 20fd86929..629d4b845 100644 --- a/tests/unit/backend/service/test_LiteDataService.py +++ b/tests/unit/backend/service/test_LiteDataService.py @@ -6,6 +6,7 @@ import pytest from mantid.simpleapi import CloneWorkspace, CreateSingleValuedWorkspace + from snapred.backend.service.LiteDataService import LiteDataService from snapred.meta.Config import Resource diff --git a/tests/unit/backend/service/test_NormalizationService.py b/tests/unit/backend/service/test_NormalizationService.py index 50222185b..643426035 100644 --- a/tests/unit/backend/service/test_NormalizationService.py +++ b/tests/unit/backend/service/test_NormalizationService.py @@ -9,6 +9,7 @@ CreateSingleValuedWorkspace, mtd, ) + from snapred.backend.dao.request import CalibrationWritePermissionsRequest from snapred.backend.dao.response.NormalizationResponse import NormalizationResponse from snapred.backend.error.ContinueWarning import ContinueWarning @@ -25,6 +26,8 @@ "snapred.backend.log.logger": mock.Mock(), }, ): + from util.SculleryBoy import SculleryBoy + from snapred.backend.dao.indexing.IndexEntry import IndexEntry from snapred.backend.dao.request import ( FocusSpectraRequest, @@ -34,7 +37,6 @@ ) from snapred.backend.dao.state import FocusGroup from snapred.backend.service.NormalizationService import NormalizationService - from util.SculleryBoy import SculleryBoy thisService = "snapred.backend.service.NormalizationService." diff --git a/tests/unit/backend/service/test_ReductionService.py b/tests/unit/backend/service/test_ReductionService.py index 729359f28..ab1d08836 100644 --- a/tests/unit/backend/service/test_ReductionService.py +++ b/tests/unit/backend/service/test_ReductionService.py @@ -10,6 +10,14 @@ DeleteWorkspace, mtd, ) +from util.helpers import ( + arrayFromMask, + createCompatibleMask, +) +from util.InstaEats import InstaEats +from util.SculleryBoy import SculleryBoy +from util.state_helpers import reduction_root_redirect + from snapred.backend.api.RequestScheduler import RequestScheduler from snapred.backend.dao import WorkspaceMetadata from snapred.backend.dao.ingredients.ReductionIngredients import ReductionIngredients @@ -29,13 +37,6 @@ from snapred.backend.service.ReductionService import ReductionService from snapred.meta.Config import Resource from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng -from util.helpers import ( - arrayFromMask, - createCompatibleMask, -) -from util.InstaEats import InstaEats -from util.SculleryBoy import SculleryBoy -from util.state_helpers import reduction_root_redirect localMock = mock.Mock() diff --git a/tests/unit/backend/service/test_SousChef.py b/tests/unit/backend/service/test_SousChef.py index efa9d71d2..84424d2c4 100644 --- a/tests/unit/backend/service/test_SousChef.py +++ b/tests/unit/backend/service/test_SousChef.py @@ -4,6 +4,7 @@ from unittest import mock from mantid.simpleapi import DeleteWorkspace, mtd + from snapred.backend.dao.CrystallographicInfo import CrystallographicInfo from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.dao.request.FarmFreshIngredients import FarmFreshIngredients diff --git a/tests/unit/backend/service/test_WorkspaceMetadataService.py b/tests/unit/backend/service/test_WorkspaceMetadataService.py index e784b0756..147d0107f 100644 --- a/tests/unit/backend/service/test_WorkspaceMetadataService.py +++ b/tests/unit/backend/service/test_WorkspaceMetadataService.py @@ -3,10 +3,11 @@ import pytest from mantid.simpleapi import AddSampleLogMultiple, CreateSingleValuedWorkspace, mtd from pydantic import ValidationError +from util.helpers import deleteWorkspaceNoThrow + from snapred.backend.dao.WorkspaceMetadata import WorkspaceMetadata from snapred.backend.service.WorkspaceMetadataService import WorkspaceMetadataService from snapred.meta.Config import Config -from util.helpers import deleteWorkspaceNoThrow thisService = "snapred.backend.service.WorkspaceMetadataService." TAG_PREFIX = Config["metadata.tagPrefix"] diff --git a/tests/unit/backend/service/test_WorkspaceService.py b/tests/unit/backend/service/test_WorkspaceService.py index de4344c23..4c69f24ad 100644 --- a/tests/unit/backend/service/test_WorkspaceService.py +++ b/tests/unit/backend/service/test_WorkspaceService.py @@ -2,6 +2,7 @@ from unittest.mock import MagicMock from mantid.simpleapi import CreateSingleValuedWorkspace, GroupWorkspaces, mtd + from snapred.backend.dao.request import ( ListWorkspacesRequest, RenameWorkspacesFromTemplateRequest, diff --git a/tests/unit/backend/test_main.py b/tests/unit/backend/test_main.py index f60f6c3a9..7bcfa17a2 100644 --- a/tests/unit/backend/test_main.py +++ b/tests/unit/backend/test_main.py @@ -1,4 +1,5 @@ import pytest + from snapred.__main__ import main diff --git a/tests/unit/meta/mantid/test_WorkspaceNameGenerator.py b/tests/unit/meta/mantid/test_WorkspaceNameGenerator.py index 145cd220b..b2982317e 100644 --- a/tests/unit/meta/mantid/test_WorkspaceNameGenerator.py +++ b/tests/unit/meta/mantid/test_WorkspaceNameGenerator.py @@ -4,6 +4,7 @@ import pytest from pydantic import BaseModel, ConfigDict + from snapred.meta.Config import Config from snapred.meta.mantid.WorkspaceNameGenerator import ( VERSION_DEFAULT, diff --git a/tests/unit/meta/test_Callback.py b/tests/unit/meta/test_Callback.py index 8fc184128..b215b3e1b 100644 --- a/tests/unit/meta/test_Callback.py +++ b/tests/unit/meta/test_Callback.py @@ -1,6 +1,7 @@ import unittest import pytest + from snapred.meta.Callback import callback diff --git a/tests/unit/meta/test_Config.py b/tests/unit/meta/test_Config.py index 1dac59d7c..8710758a2 100644 --- a/tests/unit/meta/test_Config.py +++ b/tests/unit/meta/test_Config.py @@ -7,6 +7,7 @@ from unittest import mock import pytest + import snapred.meta.Config as Config_module from snapred.meta.Config import Config, Resource, _find_root_dir, fromMantidLoggingLevel diff --git a/tests/unit/meta/test_Decorators.py b/tests/unit/meta/test_Decorators.py index 09c111c54..138e8b18a 100644 --- a/tests/unit/meta/test_Decorators.py +++ b/tests/unit/meta/test_Decorators.py @@ -7,6 +7,7 @@ import pytest from pydantic import BaseModel from qtpy.QtWidgets import QWidget + from snapred.backend.dao.SNAPRequest import SNAPRequest from snapred.backend.error.ContinueWarning import ContinueWarning from snapred.backend.error.RecoverableException import RecoverableException diff --git a/tests/unit/meta/test_redantic.py b/tests/unit/meta/test_redantic.py index b05e332e0..32249b9ad 100644 --- a/tests/unit/meta/test_redantic.py +++ b/tests/unit/meta/test_redantic.py @@ -4,6 +4,7 @@ import pytest from pydantic import BaseModel + from snapred.meta.Config import Resource from snapred.meta.redantic import ( list_from_raw, diff --git a/tests/unit/ui/presenter/test_CalibrationAssessmentPresenter.py b/tests/unit/ui/presenter/test_CalibrationAssessmentPresenter.py index 00e170225..624692409 100644 --- a/tests/unit/ui/presenter/test_CalibrationAssessmentPresenter.py +++ b/tests/unit/ui/presenter/test_CalibrationAssessmentPresenter.py @@ -1,12 +1,13 @@ from unittest.mock import MagicMock, patch import pytest + from snapred.backend.dao.request.CalibrationLoadAssessmentRequest import CalibrationLoadAssessmentRequest from snapred.backend.dao.SNAPRequest import SNAPRequest from snapred.ui.presenter.CalibrationAssessmentPresenter import CalibrationAssessmentPresenter -@pytest.fixture() +@pytest.fixture def calibrationAssessmentPresenter(): view = MagicMock() return CalibrationAssessmentPresenter(view=view) diff --git a/tests/unit/ui/presenter/test_InitializeStatePresenter.py b/tests/unit/ui/presenter/test_InitializeStatePresenter.py index d5bb24b4d..07ff9a923 100644 --- a/tests/unit/ui/presenter/test_InitializeStatePresenter.py +++ b/tests/unit/ui/presenter/test_InitializeStatePresenter.py @@ -3,10 +3,11 @@ import pytest from qtpy.QtWidgets import QApplication, QWidget +from util.script_as_test import not_a_test + from snapred.backend.dao.SNAPResponse import ResponseCode, SNAPResponse from snapred.ui.presenter.InitializeStatePresenter import InitializeStatePresenter from snapred.ui.widget.LoadingCursor import LoadingCursor -from util.script_as_test import not_a_test app = QApplication(sys.argv) @@ -23,7 +24,7 @@ def __init__(self, *args, **kwargs): self.beginFlowButton = MagicMock() -@pytest.fixture() +@pytest.fixture def setup_view_and_workflow(): view = TestableQWidget() workflow = InitializeStatePresenter(view=view) diff --git a/tests/unit/ui/widget/test_Workflow.py b/tests/unit/ui/widget/test_Workflow.py index a1d6a5e8d..2e4c62ccf 100644 --- a/tests/unit/ui/widget/test_Workflow.py +++ b/tests/unit/ui/widget/test_Workflow.py @@ -3,11 +3,12 @@ import pytest from qtpy.QtCore import Qt, Slot from qtpy.QtWidgets import QGridLayout, QPushButton, QWidget + from snapred.ui.model.WorkflowNodeModel import WorkflowNodeModel from snapred.ui.workflow.WorkflowBuilder import WorkflowBuilder -@pytest.fixture() +@pytest.fixture def qtbot(qtbot): return qtbot diff --git a/tests/unit/ui/workflow/test_DiffCalWorkflow.py b/tests/unit/ui/workflow/test_DiffCalWorkflow.py index c58a09077..1199f89c2 100644 --- a/tests/unit/ui/workflow/test_DiffCalWorkflow.py +++ b/tests/unit/ui/workflow/test_DiffCalWorkflow.py @@ -10,6 +10,7 @@ ) from qtpy.QtCore import Qt from qtpy.QtWidgets import QApplication, QMessageBox + from snapred.meta.mantid.FitPeaksOutput import FIT_PEAK_DIAG_SUFFIX, FitOutputEnum from snapred.meta.pointer import create_pointer from snapred.ui.workflow.DiffCalWorkflow import DiffCalWorkflow diff --git a/tests/unit/ui/workflow/test_WorkflowImplementer.py b/tests/unit/ui/workflow/test_WorkflowImplementer.py index 1bbe792de..2414c41e1 100644 --- a/tests/unit/ui/workflow/test_WorkflowImplementer.py +++ b/tests/unit/ui/workflow/test_WorkflowImplementer.py @@ -2,6 +2,7 @@ from unittest.mock import MagicMock from mantid.simpleapi import CreateSingleValuedWorkspace, GroupWorkspaces, mtd + from snapred.ui.workflow.WorkflowImplementer import WorkflowImplementer diff --git a/tests/util/Config_helpers.py b/tests/util/Config_helpers.py index 931bf9307..af2877133 100644 --- a/tests/util/Config_helpers.py +++ b/tests/util/Config_helpers.py @@ -3,6 +3,7 @@ from typing import Any, Dict, Tuple import pytest + from snapred.meta.Config import Config Node = namedtuple("Node", "dict key") @@ -48,7 +49,7 @@ def lookupNode(dict_: Dict[str, Any], key: str) -> Tuple[Dict[str, Any], str]: _savedNode.dict[_savedNode.key] = _savedValue -@pytest.fixture() +@pytest.fixture def Config_override_fixture(): _stack = ExitStack() diff --git a/tests/util/IPTS_override.py b/tests/util/IPTS_override.py index 865b7de3b..19821db10 100644 --- a/tests/util/IPTS_override.py +++ b/tests/util/IPTS_override.py @@ -3,9 +3,10 @@ import pytest from mantid.kernel import amend_config -from snapred.meta.Config import Config, datasearch_directories from util.Config_helpers import Config_override +from snapred.meta.Config import Config, datasearch_directories + # In order to allow convenient usage within CIS-test scripts, # `IPTS_override` is deliberately _not_ implemented as a test fixture. @@ -54,7 +55,7 @@ def IPTS_override(basePath: str = Config["IPTS.root"], instrumentName: str = Con stack.close() -@pytest.fixture() +@pytest.fixture def IPTS_override_fixture(): _stack = ExitStack() diff --git a/tests/util/InstaEats.py b/tests/util/InstaEats.py index 8b270d526..6a224a9bd 100644 --- a/tests/util/InstaEats.py +++ b/tests/util/InstaEats.py @@ -5,13 +5,14 @@ from mantid.simpleapi import LoadDetectorsGroupingFile, LoadEmptyInstrument, mtd from pydantic import validate_call +from util.WhateversInTheFridge import WhateversInTheFridge + from snapred.backend.dao.ingredients import GroceryListItem from snapred.backend.dao.state import DetectorState from snapred.backend.data.GroceryService import GroceryService from snapred.meta.Config import Config, Resource from snapred.meta.decorators.Singleton import Singleton from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceName -from util.WhateversInTheFridge import WhateversInTheFridge @Singleton diff --git a/tests/util/SculleryBoy.py b/tests/util/SculleryBoy.py index 99752c50a..d8c4382b5 100644 --- a/tests/util/SculleryBoy.py +++ b/tests/util/SculleryBoy.py @@ -2,6 +2,8 @@ from unittest import mock import pydantic +from util.dao import DAOFactory + from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.dao.ingredients import ( DiffractionCalibrationIngredients, @@ -17,7 +19,6 @@ from snapred.backend.recipe.GenericRecipe import DetectorPeakPredictorRecipe from snapred.meta.Config import Resource from snapred.meta.redantic import parse_file_as -from util.dao import DAOFactory class SculleryBoy: diff --git a/tests/util/WhateversInTheFridge.py b/tests/util/WhateversInTheFridge.py index f37a7a73d..03483ad11 100644 --- a/tests/util/WhateversInTheFridge.py +++ b/tests/util/WhateversInTheFridge.py @@ -6,6 +6,8 @@ from mantid.simpleapi import CreateSingleValuedWorkspace, mtd from pydantic import validate_call +from util.dao import DAOFactory + from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters from snapred.backend.dao.normalization.NormalizationRecord import NormalizationRecord @@ -22,7 +24,6 @@ from snapred.meta.decorators.ExceptionHandler import ExceptionHandler from snapred.meta.decorators.Singleton import Singleton from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng -from util.dao import DAOFactory logger = snapredLogger.getLogger(__name__) diff --git a/tests/util/diffraction_calibration_synthetic_data.py b/tests/util/diffraction_calibration_synthetic_data.py index f6d6db08a..a8c964fca 100644 --- a/tests/util/diffraction_calibration_synthetic_data.py +++ b/tests/util/diffraction_calibration_synthetic_data.py @@ -23,14 +23,15 @@ ScaleX, mtd, ) +from util.dao import DAOFactory +from util.helpers import * + from snapred.backend.dao import CrystallographicInfo from snapred.backend.dao.DetectorPeak import DetectorPeak from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.dao.ingredients import DiffractionCalibrationIngredients from snapred.backend.dao.RunConfig import RunConfig from snapred.meta.Config import Resource -from util.dao import DAOFactory -from util.helpers import * Peak = namedtuple("Peak", "centre sigma height") diff --git a/tests/util/golden_data.py b/tests/util/golden_data.py index 49d2b13a7..155c8261b 100644 --- a/tests/util/golden_data.py +++ b/tests/util/golden_data.py @@ -77,7 +77,7 @@ def __eq__(self, other) -> bool: return status -@pytest.fixture() +@pytest.fixture def goldenDataFilePath(request) -> Path: # Generate a golden-data file path from test marker information: # * as " / _.json". @@ -93,7 +93,7 @@ def goldenDataFilePath(request) -> Path: return Path(basePath) / f"{shortName}_{goldenDataDate}.json" -@pytest.fixture() +@pytest.fixture def goldenData(goldenDataFilePath): # Obtain the golden-data corresponding to test marker information: # * returns a namedtuple: (, , ) diff --git a/tests/util/groupingMapUtil.py b/tests/util/groupingMapUtil.py index f4a6e02b7..0d1e0cfa9 100644 --- a/tests/util/groupingMapUtil.py +++ b/tests/util/groupingMapUtil.py @@ -1,4 +1,5 @@ import pytest + from snapred.meta.Config import Resource @@ -35,6 +36,6 @@ def emptyGroups(self): return {"stateId": "deadbeef00000003", "liteFocusGroups": [], "nativeFocusGroups": []} -@pytest.fixture() +@pytest.fixture def groupingMapFactory(): return GroupingMapTestFactory() diff --git a/tests/util/instrument_helpers.py b/tests/util/instrument_helpers.py index e72e1cecb..6fbf6a11f 100644 --- a/tests/util/instrument_helpers.py +++ b/tests/util/instrument_helpers.py @@ -8,6 +8,7 @@ DeleteWorkspace, mtd, ) + from snapred.backend.dao.state.DetectorState import DetectorState diff --git a/tests/util/pytest_helpers.py b/tests/util/pytest_helpers.py index d5b6a67e2..d8f1dee28 100644 --- a/tests/util/pytest_helpers.py +++ b/tests/util/pytest_helpers.py @@ -65,7 +65,7 @@ def _cleanup_workspace_at_exit(wsName: str): pass -@pytest.fixture() +@pytest.fixture def get_unique_timestamp(): """ This method re-uses code from `LocalDataService.getUniqueTimestamp`. diff --git a/tests/util/reduction_mask_helpers.py b/tests/util/reduction_mask_helpers.py index f439d3ff7..ee7dcdea2 100644 --- a/tests/util/reduction_mask_helpers.py +++ b/tests/util/reduction_mask_helpers.py @@ -8,16 +8,17 @@ LoadInstrument, mtd, ) -from snapred.backend.dao.state.DetectorState import DetectorState -from snapred.meta.mantid.WorkspaceNameGenerator import ( - WorkspaceName, -) from util.helpers import ( createCompatibleMask, initializeRandomMask, ) from util.instrument_helpers import addInstrumentLogs, getInstrumentLogDescriptors +from snapred.backend.dao.state.DetectorState import DetectorState +from snapred.meta.mantid.WorkspaceNameGenerator import ( + WorkspaceName, +) + # Import required test fixtures at the end of either the main `conftest.py`, # or any `conftest.py` at the test-module directory. diff --git a/tests/util/state_helpers.py b/tests/util/state_helpers.py index de1e69415..90ad73742 100644 --- a/tests/util/state_helpers.py +++ b/tests/util/state_helpers.py @@ -5,6 +5,7 @@ import pytest from pydantic import BaseModel + from snapred.backend.data.LocalDataService import LocalDataService from snapred.meta.Config import Resource from snapred.meta.redantic import write_model_pretty @@ -44,7 +45,7 @@ def state_root_override(runNumber: str, name: str, useLiteMode: bool = False, de shutil.rmtree(stateRoot) -@pytest.fixture() +@pytest.fixture def state_root_fixture(): _stack = ExitStack() diff --git a/tests/util_tests/test_Config_helpers.py b/tests/util_tests/test_Config_helpers.py index 890635902..8ccb94aa4 100644 --- a/tests/util_tests/test_Config_helpers.py +++ b/tests/util_tests/test_Config_helpers.py @@ -1,8 +1,9 @@ # Unit tests for `tests/util/Config_helpers.py` -from snapred.meta.Config import Config from util.Config_helpers import Config_override +from snapred.meta.Config import Config + def test_Config_override_enter(): newPath = "some/new/path" diff --git a/tests/util_tests/test_IPTS_override.py b/tests/util_tests/test_IPTS_override.py index fb82d0053..544e60b02 100644 --- a/tests/util_tests/test_IPTS_override.py +++ b/tests/util_tests/test_IPTS_override.py @@ -5,9 +5,10 @@ from mantid.kernel import ConfigService from mantid.simpleapi import GetIPTS -from snapred.meta.Config import Config, Resource from util.IPTS_override import IPTS_override +from snapred.meta.Config import Config, Resource + def touch(path): with open(path, "a"): diff --git a/tests/util_tests/test_golden_data.py b/tests/util_tests/test_golden_data.py index 4af94e6bb..6183cfbc4 100644 --- a/tests/util_tests/test_golden_data.py +++ b/tests/util_tests/test_golden_data.py @@ -5,9 +5,10 @@ from pathlib import Path import pytest -from snapred.meta.Config import Resource from util.golden_data import ApproxAnyNested, _isPrimitive, assertMatchToGoldenData +from snapred.meta.Config import Resource + # Generate a temporary golden-data directory, that will be automatically deleted at the end of the module's execution. # * Note that pytest collection occurs at import: all _marker_ definitions must be resolved at that time. _stack = ExitStack() diff --git a/tests/util_tests/test_state_helpers.py b/tests/util_tests/test_state_helpers.py index 360626365..77499884d 100644 --- a/tests/util_tests/test_state_helpers.py +++ b/tests/util_tests/test_state_helpers.py @@ -5,12 +5,13 @@ from shutil import rmtree import pytest +from util.dao import DAOFactory +from util.state_helpers import reduction_root_redirect, state_root_override, state_root_redirect + from snapred.backend.dao.indexing.Versioning import VERSION_DEFAULT from snapred.backend.data.LocalDataService import LocalDataService from snapred.meta.Config import Config from snapred.meta.mantid.WorkspaceNameGenerator import ValueFormatter as wnvf -from util.dao import DAOFactory -from util.state_helpers import reduction_root_redirect, state_root_override, state_root_redirect @pytest.fixture(autouse=True)