blob: b4f7f368d65411aa0a3e2d7180c1fbf5b77c111f [file] [log] [blame]
# Copyright 2021 The Pigweed Authors
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Tests for pw_console.console_app"""
import logging
import unittest
from prompt_toolkit.application import create_app_session
from prompt_toolkit.output import ColorDepth
# inclusive-language: ignore
from prompt_toolkit.output import DummyOutput as FakeOutput
from pw_console.console_app import ConsoleApp
class TestConsoleApp(unittest.TestCase):
"""Tests for ConsoleApp."""
def test_instantiate(self) -> None:
"""Test init."""
with create_app_session(output=FakeOutput()):
console_app = ConsoleApp(color_depth=ColorDepth.DEPTH_8_BIT)
def test_multiple_loggers_in_one_pane(self) -> None:
"""Test window resizing."""
# pylint: disable=protected-access
with create_app_session(output=FakeOutput()):
console_app = ConsoleApp(color_depth=ColorDepth.DEPTH_8_BIT)
loggers = {
'Logs': [
for window_title, logger_instances in loggers.items():
console_app.add_log_handler(window_title, logger_instances)
# Two panes, one for the loggers and one for the repl.
window_list = console_app.window_manager.first_window_list()
self.assertEqual(len(window_list.active_panes), 2)
self.assertEqual(window_list.active_panes[0].pane_title(), 'Logs')
'test_log1, test_log2, test_log3')
'test_log1 + 3 more')
if __name__ == '__main__':