Skip to content

Commit 2fb5bf3

Browse files
committed
TEST: Check cases when fileobj is passed
1 parent 26f6f0a commit 2fb5bf3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

nibabel/tests/test_openers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,29 @@ def test_DeterministicGzipFile():
415415
assert md5sum("filenameA.gz") == anon_chksum
416416

417417

418+
def test_DeterministicGzipFile_fileobj():
419+
with InTemporaryDirectory():
420+
msg = b"Hello, I'd like to have an argument."
421+
with open("ref.gz", "wb") as fobj:
422+
with GzipFile(filename="", mode="wb", fileobj=fobj, mtime=0) as gzobj:
423+
gzobj.write(msg)
424+
ref_chksum = md5sum("ref.gz")
425+
426+
with open("test.gz", "wb") as fobj:
427+
with DeterministicGzipFile(filename="", mode="wb", fileobj=fobj) as gzobj:
428+
gzobj.write(msg)
429+
md5sum("test.gz") == ref_chksum
430+
431+
with open("test.gz", "wb") as fobj:
432+
with DeterministicGzipFile(fileobj=fobj, mode="wb") as gzobj:
433+
gzobj.write(msg)
434+
md5sum("test.gz") == ref_chksum
435+
436+
with open("test.gz", "wb") as fobj:
437+
with DeterministicGzipFile(filename="test.gz", mode="wb", fileobj=fobj) as gzobj:
438+
gzobj.write(msg)
439+
md5sum("test.gz") == ref_chksum
440+
418441

419442
def test_bitwise_determinism():
420443
with InTemporaryDirectory():

0 commit comments

Comments
 (0)