Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrize test_seek_mode functions #7847

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Changes from all 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
41 changes: 10 additions & 31 deletions Tests/test_file_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ def test_isatty() -> None:
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
mode = 0
with open(TEST_FILE, "rb") as fh:
container = ContainerIO.ContainerIO(fh, 22, 100)

Expand All @@ -32,35 +39,7 @@ def test_seek_mode_0() -> None:
container.seek(33, mode)

# Assert
assert container.tell() == 33


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
assert container.tell() == expected_value


@pytest.mark.parametrize("bytesmode", (True, False))
Expand Down
Loading