summaryrefslogtreecommitdiffstats
path: root/tests/test_terminal_io/__init__.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-16 09:09:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-16 09:09:35 +0000
commit0dfe1c9e2780469e3a4696e8fb3e6f717a7ebeb7 (patch)
treea0b651b55ea02e3b00bbc5eedba566fdd6bd7c08 /tests/test_terminal_io/__init__.py
parentInitial commit. (diff)
downloadterminaltables-0dfe1c9e2780469e3a4696e8fb3e6f717a7ebeb7.tar.xz
terminaltables-0dfe1c9e2780469e3a4696e8fb3e6f717a7ebeb7.zip
Adding upstream version 3.1.0.upstream/3.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_terminal_io/__init__.py')
-rw-r--r--tests/test_terminal_io/__init__.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_terminal_io/__init__.py b/tests/test_terminal_io/__init__.py
new file mode 100644
index 0000000..93738fc
--- /dev/null
+++ b/tests/test_terminal_io/__init__.py
@@ -0,0 +1,45 @@
+"""Common objects used by tests in directory."""
+
+from terminaltables import terminal_io
+
+
+class MockKernel32(object):
+ """Mock kernel32."""
+
+ def __init__(self, stderr=terminal_io.INVALID_HANDLE_VALUE, stdout=terminal_io.INVALID_HANDLE_VALUE):
+ """Constructor."""
+ self.stderr = stderr
+ self.stdout = stdout
+ self.csbi_err = b'x\x00)#\x00\x00\x87\x05\x07\x00\x00\x00j\x05w\x00\x87\x05x\x00J\x00' # 119 x 29
+ self.csbi_out = b'L\x00,\x01\x00\x00*\x01\x07\x00\x00\x00\x0e\x01K\x00*\x01L\x00L\x00' # 75 x 28
+ self.setConsoleTitleA_called = False
+ self.setConsoleTitleW_called = False
+
+ def GetConsoleScreenBufferInfo(self, handle, lpcsbi): # noqa
+ """Mock GetConsoleScreenBufferInfo.
+
+ :param handle: Unused handle.
+ :param lpcsbi: ctypes.create_string_buffer() return value.
+ """
+ if handle == self.stderr:
+ lpcsbi.raw = self.csbi_err
+ else:
+ lpcsbi.raw = self.csbi_out
+ return 1
+
+ def GetStdHandle(self, handle): # noqa
+ """Mock GetStdHandle.
+
+ :param int handle: STD_ERROR_HANDLE or STD_OUTPUT_HANDLE.
+ """
+ return self.stderr if handle == terminal_io.STD_ERROR_HANDLE else self.stdout
+
+ def SetConsoleTitleA(self, _): # noqa
+ """Mock SetConsoleTitleA."""
+ self.setConsoleTitleA_called = True
+ return 1
+
+ def SetConsoleTitleW(self, _): # noqa
+ """Mock SetConsoleTitleW."""
+ self.setConsoleTitleW_called = True
+ return 1