mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
Merge pull request #7847 from Yay295/patch-1
Parametrize test_seek_mode functions
This commit is contained in:
commit
2bd54260b6
|
@ -21,9 +21,16 @@ def test_isatty() -> None:
|
||||||
assert container.isatty() is False
|
assert container.isatty() is False
|
||||||
|
|
||||||
|
|
||||||
def test_seek_mode_0() -> None:
|
@pytest.mark.parametrize(
|
||||||
|
"mode, expected_value",
|
||||||
|
(
|
||||||
|
(0, 33),
|
||||||
|
(1, 66),
|
||||||
|
(2, 100),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_seek_mode(mode: int, expected_value: int) -> None:
|
||||||
# Arrange
|
# Arrange
|
||||||
mode = 0
|
|
||||||
with open(TEST_FILE, "rb") as fh:
|
with open(TEST_FILE, "rb") as fh:
|
||||||
container = ContainerIO.ContainerIO(fh, 22, 100)
|
container = ContainerIO.ContainerIO(fh, 22, 100)
|
||||||
|
|
||||||
|
@ -32,35 +39,7 @@ def test_seek_mode_0() -> None:
|
||||||
container.seek(33, mode)
|
container.seek(33, mode)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert container.tell() == 33
|
assert container.tell() == expected_value
|
||||||
|
|
||||||
|
|
||||||
def test_seek_mode_1() -> None:
|
|
||||||
# Arrange
|
|
||||||
mode = 1
|
|
||||||
with open(TEST_FILE, "rb") as fh:
|
|
||||||
container = ContainerIO.ContainerIO(fh, 22, 100)
|
|
||||||
|
|
||||||
# Act
|
|
||||||
container.seek(33, mode)
|
|
||||||
container.seek(33, mode)
|
|
||||||
|
|
||||||
# Assert
|
|
||||||
assert container.tell() == 66
|
|
||||||
|
|
||||||
|
|
||||||
def test_seek_mode_2() -> None:
|
|
||||||
# Arrange
|
|
||||||
mode = 2
|
|
||||||
with open(TEST_FILE, "rb") as fh:
|
|
||||||
container = ContainerIO.ContainerIO(fh, 22, 100)
|
|
||||||
|
|
||||||
# Act
|
|
||||||
container.seek(33, mode)
|
|
||||||
container.seek(33, mode)
|
|
||||||
|
|
||||||
# Assert
|
|
||||||
assert container.tell() == 100
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("bytesmode", (True, False))
|
@pytest.mark.parametrize("bytesmode", (True, False))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user