From 39553dd1c40a401f272386336481e374efa51837 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Fri, 20 Sep 2024 11:54:50 +1000 Subject: [PATCH] fixed unittests --- .../extras/application/tests/test_application_medical.py | 6 +++--- fileformats/generic/file.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extras/fileformats/extras/application/tests/test_application_medical.py b/extras/fileformats/extras/application/tests/test_application_medical.py index 71aafdb..aa270f4 100644 --- a/extras/fileformats/extras/application/tests/test_application_medical.py +++ b/extras/fileformats/extras/application/tests/test_application_medical.py @@ -6,13 +6,13 @@ def test_dicom_metadata(): dicom = Dicom.sample() - assert dicom.metadata["EchoTime"] == "2.07" + assert dicom.metadata["EchoTime"] == 2.07 def test_dicom_metadata_with_specific_tags(): - dicom = Dicom(Dicom.sample(), specific_tags=["EchoTime"]) + dicom = Dicom(Dicom.sample(), metadata_keys=["EchoTime"]) - assert dicom.metadata["EchoTime"] == "2.07" + assert dicom.metadata["EchoTime"] == 2.07 with pytest.raises(KeyError): dicom.metadata["PatientName"] diff --git a/fileformats/generic/file.py b/fileformats/generic/file.py index 95bfc72..d4002da 100644 --- a/fileformats/generic/file.py +++ b/fileformats/generic/file.py @@ -106,7 +106,7 @@ def open( def read_contents( self, size: ty.Optional[int] = None, offset: int = 0 ) -> ty.Union[str, bytes]: - with self.open("rb") as f: + with self.open("rb" if getattr(self, "binary", True) else "r") as f: if offset: f.seek(offset, (io.SEEK_SET if offset >= 0 else io.SEEK_END)) contents = f.read(size) if size else f.read()