Skip to content

Commit e4fcc95

Browse files
committed
WIP test_accessor: write into copy file as binary
This works properly for the http case, but FileAccessor provides us with a text fileobj handle, and `read()` gets a UTF-8 decoding error. FIXME: Accessor ctor requires a `mode` argument
1 parent bb89503 commit e4fcc95

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/test_accessor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ def test_file_binfile(self):
2323
a.start()
2424
self.assertTrue(a.access(BINFILE))
2525
inf = a.openAddress(BINFILE)
26-
with NamedTemporaryFile("w") as outf:
27-
outf.writelines(inf)
26+
with NamedTemporaryFile("wb") as outf:
27+
while True:
28+
data = inf.read()
29+
if not data: # EOF
30+
break
31+
outf.write(data)
2832
outf.flush()
2933
hasher = hashlib.md5()
3034
with open(outf.name, "rb") as bincontents:

0 commit comments

Comments
 (0)