Coverage for tests/unit/TerminalUI.py: 85%
25 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-10-05 22:21 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-10-05 22:21 +0000
1# =============================================================================
2# _____ _ _ _ _ ___
3# _ __ _ |_ _|__ _ __ _ __ ___ (_)_ __ __ _| | | | |_ _|
4# | '_ \| | | || |/ _ \ '__| '_ ` _ \| | '_ \ / _` | | | | || |
5# | |_) | |_| || | __/ | | | | | | | | | | | (_| | | |_| || |
6# | .__/ \__, ||_|\___|_| |_| |_| |_|_|_| |_|\__,_|_|\___/|___|
7# |_| |___/
8# =============================================================================
9# Authors: Patrick Lehmann
10#
11# Python unittest: Testing the pyTooling.TerminalUI module
12#
13# License:
14# ============================================================================
15# Copyright 2017-2022 Patrick Lehmann - Bötzingen, Germany
16# Copyright 2007-2016 Patrick Lehmann - Dresden, Germany
17#
18# Licensed under the Apache License, Version 2.0 (the "License");
19# you may not use this file except in compliance with the License.
20# You may obtain a copy of the License at
21#
22# http://www.apache.org/licenses/LICENSE-2.0
23#
24# Unless required by applicable law or agreed to in writing, software
25# distributed under the License is distributed on an "AS IS" BASIS,
26# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27# See the License for the specific language governing permissions and
28# limitations under the License.
29#
30# SPDX-License-Identifier: Apache-2.0
31# ============================================================================
32#
33"""
34pyTooling.TerminalUI
35####################
37:copyright: Copyright 2007-2022 Patrick Lehmann - Bötzingen, Germany
38:license: Apache License, Version 2.0
39"""
40from unittest import TestCase
42from pyTooling.TerminalUI import LineTerminal
45if __name__ == "__main__": # pragma: no cover 45 ↛ 46line 45 didn't jump to line 46, because the condition on line 45 was never true
46 print("ERROR: you called a testcase declaration file as an executable module.")
47 print("Use: 'python -m unitest <testcase module>'")
48 exit(1)
51class Application(LineTerminal):
52 def __init__(self):
53 super().__init__(verbose=True, debug=True, quiet=False)
55 LineTerminal.FATAL_EXIT_CODE = 0
58class Terminal(TestCase):
59 app : Application
61 def setUp(self) -> None:
62 self.app = Application()
64 def test_Version(self) -> None:
65 Application.versionCheck((3, 6, 0))
67 def test_Write(self) -> None:
68 self.app.WriteQuiet("This is a quiet message.")
69 self.app.WriteNormal("This is a normal message.")
70 self.app.WriteInfo("This is a info message.")
71 self.app.WriteDebug("This is a debug message.")
72 self.app.WriteWarning("This is a warning message.")
73 self.app.WriteError("This is an error message.")
74 self.app.WriteFatal("This is a fatal message.", immediateExit=False)