Tweak types and fix mock persistence between tests

This commit is contained in:
Julian Stirling 2026-06-03 16:00:25 +01:00
parent 2c215b9f81
commit cdab10ae46
2 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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