-
Notifications
You must be signed in to change notification settings - Fork 111
Coverage: Test helpers #580
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8b78910
test(random): Add comprehensive tests for random test utilities
tony 647c9d1
test(temporary): Add tests for temporary session/window context managers
tony 9385862
test(random): Fix collision tests and improve coverage
tony 1a258fe
test(constants): Add tests for test constants
tony cc46b5d
test(environment): add comprehensive tests for EnvironmentVarGuard
tony 77cdce7
test(random): enhance RandomStrSequence tests
tony 09d5bdb
test(retry): improve retry_until test reliability
tony fbefdde
refactor(random): clean up imports and type hints
tony 6675ab2
test(random): enhance test coverage
tony efaa103
style(test): combine nested with statements
tony 9788b7a
tests: Clear out test/__init__.py
tony a8b3141
chore(coverage): exclude type checking from coverage
tony 92e0689
pyproject(coverage) Ignore `import typing as t`
tony 55be8e8
pyproject(coverage) Ignore protocol
tony d661ecf
chore(coverage): exclude doctest examples from coverage
tony bb24a80
test(environment): improve test coverage to 100%
tony a1ee582
style: remove unused import
tony 1476875
fix(test): Fix doctest examples in random.py
tony 1e31d9e
test: enhance RandomStrSequence testing coverage
tony e345a21
test: improve temporary context handling tests
tony e1a73bd
test: improve coverage for random test utilities
tony e295aa3
test: improve code coverage with direct tests that don't mock core me…
tony 6210ce6
test: replace multiple mocked collision tests with real tmux objects
tony a02e05a
test(random): improve test coverage for test utils
tony 39c9a79
docs(CHANGES) Note test coverage updates
tony a4658c9
docs(MIGRATION) Note `libtmux.test` import fix
tony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1 @@ | ||
"""Helper methods for libtmux and downstream libtmux libraries.""" | ||
|
||
from __future__ import annotations | ||
|
||
import contextlib | ||
import logging | ||
import os | ||
import pathlib | ||
import random | ||
import time | ||
import typing as t | ||
|
||
from libtmux.exc import WaitTimeout | ||
from libtmux.test.constants import ( | ||
RETRY_INTERVAL_SECONDS, | ||
RETRY_TIMEOUT_SECONDS, | ||
TEST_SESSION_PREFIX, | ||
) | ||
|
||
from .random import namer | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
if t.TYPE_CHECKING: | ||
import sys | ||
import types | ||
from collections.abc import Callable, Generator | ||
|
||
from libtmux.server import Server | ||
from libtmux.session import Session | ||
from libtmux.window import Window | ||
|
||
if sys.version_info >= (3, 11): | ||
from typing import Self | ||
else: | ||
from typing_extensions import Self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Tests for libtmux's test constants.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from libtmux.test.constants import ( | ||
RETRY_INTERVAL_SECONDS, | ||
RETRY_TIMEOUT_SECONDS, | ||
TEST_SESSION_PREFIX, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
import pytest | ||
|
||
|
||
def test_test_session_prefix() -> None: | ||
"""Test TEST_SESSION_PREFIX is correctly defined.""" | ||
assert TEST_SESSION_PREFIX == "libtmux_" | ||
|
||
|
||
def test_retry_timeout_seconds_default() -> None: | ||
"""Test RETRY_TIMEOUT_SECONDS default value.""" | ||
assert RETRY_TIMEOUT_SECONDS == 8 | ||
|
||
|
||
def test_retry_timeout_seconds_env(monkeypatch: pytest.MonkeyPatch) -> None: | ||
"""Test RETRY_TIMEOUT_SECONDS can be configured via environment variable.""" | ||
monkeypatch.setenv("RETRY_TIMEOUT_SECONDS", "10") | ||
from importlib import reload | ||
|
||
import libtmux.test.constants | ||
|
||
reload(libtmux.test.constants) | ||
assert libtmux.test.constants.RETRY_TIMEOUT_SECONDS == 10 | ||
|
||
|
||
def test_retry_interval_seconds_default() -> None: | ||
"""Test RETRY_INTERVAL_SECONDS default value.""" | ||
assert RETRY_INTERVAL_SECONDS == 0.05 | ||
|
||
|
||
def test_retry_interval_seconds_env(monkeypatch: pytest.MonkeyPatch) -> None: | ||
"""Test RETRY_INTERVAL_SECONDS can be configured via environment variable.""" | ||
monkeypatch.setenv("RETRY_INTERVAL_SECONDS", "0.1") | ||
from importlib import reload | ||
|
||
import libtmux.test.constants | ||
|
||
reload(libtmux.test.constants) | ||
assert libtmux.test.constants.RETRY_INTERVAL_SECONDS == 0.1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.