Skip to content

Commit

Permalink
test: Update tests for top-level definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymouX47 committed Sep 8, 2024
1 parent f09504b commit 7f8d78f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/test_top_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from term_image import (
AutoCellRatio,
_utils,
disable_queries,
disable_win_size_swap,
enable_queries,
enable_win_size_swap,
get_cell_ratio,
set_cell_ratio,
set_query_timeout,
utils,
)
from term_image.exceptions import TermImageError
from term_image.geometry import Size
Expand Down Expand Up @@ -72,40 +72,40 @@ def test_dynamic(self):


def test_disable_queries():
utils._queries_enabled = True
_utils._queries_enabled = True

disable_queries()
assert not utils._queries_enabled
assert not _utils._queries_enabled


@pytest.mark.parametrize("was_enabled", [True, False])
def test_disable_win_size_swap(was_enabled):
utils._swap_win_size = was_enabled
utils._cell_size_cache[:] = (1, 2, 3, 4)
_utils._swap_win_size = was_enabled
_utils._cell_size_cache[:] = (1, 2, 3, 4)

disable_win_size_swap()
assert not utils._swap_win_size
assert utils._cell_size_cache == [0, 0, 0, 0] if was_enabled else [1, 2, 3, 4]
assert not _utils._swap_win_size
assert _utils._cell_size_cache == [0, 0, 0, 0] if was_enabled else [1, 2, 3, 4]


@pytest.mark.parametrize("was_enabled", [True, False])
def test_enable_queries(was_enabled):
utils._queries_enabled = was_enabled
utils._cell_size_cache[:] = (1, 2, 3, 4)
_utils._queries_enabled = was_enabled
_utils._cell_size_cache[:] = (1, 2, 3, 4)

enable_queries()
assert utils._queries_enabled
assert utils._cell_size_cache == [1, 2, 3, 4] if was_enabled else [0, 0, 0, 0]
assert _utils._queries_enabled
assert _utils._cell_size_cache == [1, 2, 3, 4] if was_enabled else [0, 0, 0, 0]


@pytest.mark.parametrize("was_enabled", [True, False])
def test_enable_win_size_swap(was_enabled):
utils._swap_win_size = was_enabled
utils._cell_size_cache[:] = (1, 2, 3, 4)
_utils._swap_win_size = was_enabled
_utils._cell_size_cache[:] = (1, 2, 3, 4)

enable_win_size_swap()
assert utils._swap_win_size
assert utils._cell_size_cache == [1, 2, 3, 4] if was_enabled else [0, 0, 0, 0]
assert _utils._swap_win_size
assert _utils._cell_size_cache == [1, 2, 3, 4] if was_enabled else [0, 0, 0, 0]


class TestSetQueryTimeout:
Expand All @@ -117,4 +117,4 @@ def test_invalid(self, timeout):
@pytest.mark.parametrize("timeout", [0.1, 0.5, 1.0, 10.0])
def test_valid(self, timeout):
set_query_timeout(timeout)
assert utils._query_timeout == timeout
assert _utils._query_timeout == timeout

0 comments on commit 7f8d78f

Please sign in to comment.