mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Implement Preset Argument in tarfile.open Function and Add Test Coverage (#11251)
This commit is contained in:
@@ -119,6 +119,7 @@ def open(
|
||||
debug: int | None = ...,
|
||||
errorlevel: int | None = ...,
|
||||
compresslevel: int | None = ...,
|
||||
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
|
||||
) -> TarFile: ...
|
||||
|
||||
class ExFileObject(io.BufferedReader):
|
||||
|
||||
13
test_cases/stdlib/check_tarfile.py
Normal file
13
test_cases/stdlib/check_tarfile.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import tarfile
|
||||
|
||||
with tarfile.open("test.tar.xz", "w:xz") as tar:
|
||||
pass
|
||||
|
||||
# Test with valid preset values
|
||||
tarfile.open("test.tar.xz", "w:xz", preset=0)
|
||||
tarfile.open("test.tar.xz", "w:xz", preset=5)
|
||||
tarfile.open("test.tar.xz", "w:xz", preset=9)
|
||||
|
||||
# Test with invalid preset values
|
||||
tarfile.open("test.tar.xz", "w:xz", preset=-1) # type: ignore
|
||||
tarfile.open("test.tar.xz", "w:xz", preset=10) # type: ignore
|
||||
Reference in New Issue
Block a user