From 497310f589f4c1d4be103a9d6045d27dcab977fa Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 4 Nov 2024 08:43:27 +0100 Subject: [PATCH] Improve user messages --- src/dnaio/_bam.py | 4 ++-- tests/test_internal.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dnaio/_bam.py b/src/dnaio/_bam.py index 625b80c7..11ea1e72 100644 --- a/src/dnaio/_bam.py +++ b/src/dnaio/_bam.py @@ -6,13 +6,13 @@ def read_bam_header(fileobj: BufferedIOBase) -> bytes: magic = fileobj.read(4) if not isinstance(magic, bytes): raise TypeError( - f"fileobj {fileobj} is not a binary IO type, " f"got {type(fileobj)}" + f"fileobj {fileobj} (type: {type(fileobj)}), was not opened in binary mode." ) if len(magic) < 4: raise EOFError("Truncated BAM file") if magic[:4] != b"BAM\1": raise ValueError( - f"fileobj: {fileobj}, is not a BAM file. No BAM magic, instead " + f"fileobj: {fileobj}, is not a BAM file. No BAM file signature, instead " f"found {magic!r}" ) return read_bam_header_after_magic(fileobj) diff --git a/tests/test_internal.py b/tests/test_internal.py index 16ea8ab5..7b463574 100644 --- a/tests/test_internal.py +++ b/tests/test_internal.py @@ -785,7 +785,7 @@ def test_bam_parser_not_binary_error(self): ) with pytest.raises(TypeError) as error: BamReader(file) - error.match("binary IO") + error.match("binary mode") @pytest.mark.parametrize("buffersize", [4, 8, 10, 20, 40]) def test_small_buffersize(self, buffersize):