Skip to content

Commit a2c9037

Browse files
committed
make StatIO non-local
1 parent f2f2374 commit a2c9037

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Lib/test/test_zipfile/test_core.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from test.support.os_helper import (
2727
TESTFN, unlink, rmtree, temp_dir, temp_cwd, fd_count, FakePath
2828
)
29+
import _pyio
2930

3031

3132
TESTFN2 = TESTFN + "2"
@@ -3447,18 +3448,20 @@ def test_too_short(self):
34473448
self.assertEqual(
34483449
b"zzz", zipfile._Extra.strip(b"zzz", (self.ZIP64_EXTRA,)))
34493450

3451+
3452+
class StatIO(_pyio.BytesIO):
3453+
def __init__(self):
3454+
super().__init__()
3455+
self.bytes_read = 0
3456+
3457+
def read(self, size=-1):
3458+
bs = super().read(size)
3459+
self.bytes_read += len(bs)
3460+
return bs
3461+
3462+
34503463
class StoredZipExtFileRandomReadTest(unittest.TestCase):
34513464
def test_random_read(self):
3452-
from _pyio import BytesIO
3453-
class StatIO(BytesIO):
3454-
def __init__(self):
3455-
super().__init__()
3456-
self.bytes_read = 0
3457-
3458-
def read(self, size=-1):
3459-
bs = super().read(size)
3460-
self.bytes_read += len(bs)
3461-
return bs
34623465

34633466
sio = StatIO()
34643467
# 20000 bytes

0 commit comments

Comments
 (0)