1
0
Fork 0
terminaltables3/tests/test_terminal_io/test_get_console_info.py
Daniel Baumann 07735c967b
Merging upstream version 4.0.0 (Closes: #1095814).
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-12 15:00:49 +01:00

31 lines
696 B
Python

"""Test function in module."""
import ctypes
import pytest
from terminaltables3.terminal_io import (
get_console_info,
INVALID_HANDLE_VALUE,
IS_WINDOWS,
)
from tests.test_terminal_io import MockKernel32
def test():
"""Test function."""
# Test live WinError.
if IS_WINDOWS:
with pytest.raises(OSError):
get_console_info(ctypes.windll.kernel32, 0)
# Test INVALID_HANDLE_VALUE.
kernel32 = MockKernel32(stderr=1)
with pytest.raises(OSError):
get_console_info(kernel32, INVALID_HANDLE_VALUE)
# Test no error with mock methods.
width, height = get_console_info(kernel32, 1)
assert width == 119
assert height == 29