Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.13] GH-120754: Add more tests around seek + readall (GH-122103)#122215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
GH-120754: Add more tests around seek + readall (GH-122103)
In the process of speeding up readall, A number of related tests(ex. large file tests in test_zipfile) found problems with thechange I was making. This adds I/O tests to specifically test thesecases to help ensure they don't regress and hopefully make debuggingeasier.This is part of the improvements fromhttps://github.com/python/cpython/pull/121593GH-issuecomment-2222261986(cherry picked from commit9eb7341)Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
  • Loading branch information
@cmaloney@miss-islington
cmaloney authored andmiss-islington committedJul 24, 2024
commit3ffccc7da1331d4072d92cf239d1647b6593fd67
19 changes: 19 additions & 0 deletionsLib/test/test_largefile.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -141,6 +141,9 @@ def test_truncate(self):
f.truncate(1)
self.assertEqual(f.tell(), 0) # else pointer moved
f.seek(0)
# Verify readall on a truncated file is well behaved. read()
# without a size can be unbounded, this should get just the byte
# that remains.
self.assertEqual(len(f.read()), 1) # else wasn't truncated

def test_seekable(self):
Expand All@@ -151,6 +154,22 @@ def test_seekable(self):
f.seek(pos)
self.assertTrue(f.seekable())

@bigmemtest(size=size, memuse=2, dry_run=False)
def test_seek_readall(self, _size):
# Seek which doesn't change position should readall successfully.
with self.open(TESTFN, 'rb') as f:
self.assertEqual(f.seek(0, os.SEEK_CUR), 0)
self.assertEqual(len(f.read()), size + 1)

# Seek which changes (or might change) position should readall
# successfully.
with self.open(TESTFN, 'rb') as f:
self.assertEqual(f.seek(20, os.SEEK_SET), 20)
self.assertEqual(len(f.read()), size - 19)

with self.open(TESTFN, 'rb') as f:
self.assertEqual(f.seek(-3, os.SEEK_END), size - 2)
self.assertEqual(len(f.read()), 3)

def skip_no_disk_space(path, required):
def decorator(fun):
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp