Skip to content

Commit 8daf7a8

Browse files
author
Tyler Goodlet
committed
Add test to using new length kwarg
1 parent 24b2f57 commit 8daf7a8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Lib/test/test_shutil.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,14 @@ def test_copyfile_same_file(self):
14031403
# But Error should work too, to stay backward compatible.
14041404
self.assertRaises(Error, shutil.copyfile, src_file, src_file)
14051405

1406+
def test_copy_w_different_length(self):
1407+
# copy and copy2 both accept an alternate buffer `length`
1408+
for fn in (shutil.copy, shutil.copy2):
1409+
with tempfile.NamedTemporaryFile() as src:
1410+
with tempfile.NamedTemporaryFile() as dst:
1411+
write_file(src.name, b'x' * 100, binary=True)
1412+
fn(src.name, dst.name, length=20)
1413+
14061414
def test_copytree_return_value(self):
14071415
# copytree returns its destination path.
14081416
src_dir = self.mkdtemp()
@@ -1830,6 +1838,7 @@ def test_move_dir_caseinsensitive(self):
18301838
finally:
18311839
os.rmdir(dst_dir)
18321840

1841+
18331842
class TermsizeTests(unittest.TestCase):
18341843
def test_does_not_crash(self):
18351844
"""Check if get_terminal_size() returns a meaningful value.

0 commit comments

Comments
 (0)