Fix unit tests for stage_measrue as an OFMThing
This commit is contained in:
parent
5c128c1467
commit
714435f2d4
3 changed files with 25 additions and 8 deletions
|
|
@ -5,6 +5,7 @@ with other Things and including them in the LabThings-FastAPI config file.
|
|||
"""
|
||||
|
||||
import os
|
||||
from types import TracebackType
|
||||
from typing import Optional, Self
|
||||
|
||||
import labthings_fastapi as lt
|
||||
|
|
@ -35,6 +36,19 @@ class OFMThing(lt.Thing):
|
|||
)
|
||||
return self
|
||||
|
||||
def __exit__(
|
||||
self,
|
||||
_exc_type: type[BaseException],
|
||||
_exc_value: Optional[BaseException],
|
||||
_traceback: Optional[TracebackType],
|
||||
) -> None:
|
||||
"""Close the OFMThing.
|
||||
|
||||
This is needed for the context manager protocol to work. Currently it doesn't
|
||||
do anything.
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def data_dir(self) -> str:
|
||||
"""The data directory for this thing."""
|
||||
|
|
|
|||
|
|
@ -202,11 +202,7 @@ class RangeofMotionThing(OFMThing):
|
|||
|
||||
timestamp = datetime.now().strftime("%Y_%m_%d_%H_%M")
|
||||
datafile_path = os.path.join(self.data_dir, f"rom_data_{timestamp}.json")
|
||||
with open(
|
||||
datafile_path,
|
||||
"w",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
with open(datafile_path, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue