Skip to content

Commit

Permalink
fixed unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 20, 2024
1 parent 2e1cdfb commit 39553dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion fileformats/generic/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 39553dd

Please sign in to comment.