diff --git a/src/openflexure_microscope_server/things/__init__.py b/src/openflexure_microscope_server/things/__init__.py index 975be827..28a16309 100644 --- a/src/openflexure_microscope_server/things/__init__.py +++ b/src/openflexure_microscope_server/things/__init__.py @@ -112,8 +112,13 @@ class RelativeDataPath(RootModel[str]): """Return True if the saving thing is set.""" return self._saving_thing is not None - def set_saving_thing(self, thing: OFMThing) -> None: - """Set the Thing that is saving the data. This will set the data directory.""" + def set_saving_thing(self, thing: OFMThing | TemporaryDirectory) -> None: + """Set the Thing that is saving the data. + + The thing can also be a ``TemporaryDirectory`` object. + + This will set the data directory. + """ if self.save_location_set: raise RuntimeError("The saving Thing for the relative path is already set") self._saving_thing = thing diff --git a/tests/unit_tests/test_base_camera.py b/tests/unit_tests/test_base_camera.py index d9a28a73..1182d05d 100644 --- a/tests/unit_tests/test_base_camera.py +++ b/tests/unit_tests/test_base_camera.py @@ -108,7 +108,8 @@ def test_save_from_memory(test_case, test_env, mocker): camera._add_metadata_to_capture = mocker.Mock() mode = CaptureMode(description="foo", save_resolution=test_case.save_resolution) - type(camera).capture_modes = mocker.PropertyMock(return_value={"standard": mode}) + capture_modes_mock = mocker.PropertyMock(return_value={"standard": mode}) + mocker.patch.object(type(camera), "capture_modes", capture_modes_mock) mock_image = mocker.Mock() # Make resize return itself so we can track further calls of the Image object after