Skip to content

Commit 64b052a

Browse files
use support.subTests
1 parent bf5fba6 commit 64b052a

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

Lib/test/test_io/test_textio.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,28 +1425,21 @@ def test_read_non_blocking(self):
14251425
os.close(r)
14261426
os.close(w)
14271427

1428-
def test_seek_reject_negative_chars_to_skip(self):
1429-
# See https://github.com/python/cpython/issues/153662
1430-
data = b"1"
1431-
raw = io.BytesIO(data)
1432-
buf = io.BufferedReader(raw)
1433-
tio = io.TextIOWrapper(buf, encoding='utf-8')
1428+
@support.subTests('cookie_value', [
14341429
# Set 'cookie.chars_to_skip' to INT_MIN
1435-
COOKIE_VALUE = (100 << (12 * 8)) | (0x80 << (19 * 8))
1436-
tio.read()
1437-
with self.assertRaisesRegex(OSError, "can't restore logical file position"):
1438-
tio.seek(COOKIE_VALUE)
1439-
1440-
def test_seek_reject_int_max_chars_to_skip(self):
1430+
(100 << (12 * 8)) | (0x80 << (19 * 8)),
1431+
# Set 'cookie.chars_to_skip' to INT_MAX
1432+
(100 << (12 * 8)) | (0x7FFFFFFF << (16 * 8))
1433+
])
1434+
def test_seek_reject_invalid_chars_to_skip(self, cookie_value):
1435+
# See https://github.com/python/cpython/issues/153662
14411436
data = b"1"
14421437
raw = io.BytesIO(data)
14431438
buf = io.BufferedReader(raw)
14441439
tio = io.TextIOWrapper(buf, encoding='utf-8')
1445-
# Set 'cookie.chars_to_skip' to INT_MAX
1446-
COOKIE_VALUE = (100 << (12 * 8)) | (0x7FFFFFFF << (16 * 8))
14471440
tio.read()
14481441
with self.assertRaisesRegex(OSError, "can't restore logical file position"):
1449-
tio.seek(COOKIE_VALUE)
1442+
tio.seek(cookie_value)
14501443

14511444

14521445
class MemviewBytesIO(io.BytesIO):

0 commit comments

Comments
 (0)