|
| 1 | +# EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- |
| 2 | +# vim: tabstop=2:shiftwidth=2:noexpandtab |
| 3 | +# kate: tab-width 2; replace-tabs off; indent-width 2; |
| 4 | +# ============================================================================= |
| 5 | +# _____ _ _ _ _ ___ |
| 6 | +# _ __ _ |_ _|__ _ __ _ __ ___ (_)_ __ __ _| | | | |_ _| |
| 7 | +# | '_ \| | | || |/ _ \ '__| '_ ` _ \| | '_ \ / _` | | | | || | |
| 8 | +# | |_) | |_| || | __/ | | | | | | | | | | | (_| | | |_| || | |
| 9 | +# | .__/ \__, ||_|\___|_| |_| |_| |_|_|_| |_|\__,_|_|\___/|___| |
| 10 | +# |_| |___/ |
| 11 | +# ============================================================================= |
| 12 | +# Authors: Patrick Lehmann |
| 13 | +# |
| 14 | +# Python unittest: Testing the pyTerminalUI module |
| 15 | +# |
| 16 | +# Description: |
| 17 | +# ------------------------------------ |
| 18 | +# TODO |
| 19 | +# |
| 20 | +# License: |
| 21 | +# ============================================================================ |
| 22 | +# Copyright 2017-2020 Patrick Lehmann - Bötzingen, Germany |
| 23 | +# Copyright 2007-2016 Patrick Lehmann - Dresden, Germany |
| 24 | +# |
| 25 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 26 | +# you may not use this file except in compliance with the License. |
| 27 | +# You may obtain a copy of the License at |
| 28 | +# |
| 29 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 30 | +# |
| 31 | +# Unless required by applicable law or agreed to in writing, software |
| 32 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 33 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 34 | +# See the License for the specific language governing permissions and |
| 35 | +# limitations under the License. |
| 36 | +# |
| 37 | +# SPDX-License-Identifier: Apache-2.0 |
| 38 | +# ============================================================================ |
| 39 | +# |
| 40 | +""" |
| 41 | +pyAttributes |
| 42 | +############ |
| 43 | +
|
| 44 | +:copyright: Copyright 2007-2020 Patrick Lehmann - Bötzingen, Germany |
| 45 | +:license: Apache License, Version 2.0 |
| 46 | +""" |
| 47 | +from unittest import TestCase |
| 48 | + |
| 49 | +from pyTerminalUI import LineTerminal |
| 50 | + |
| 51 | + |
| 52 | +if __name__ == "__main__": |
| 53 | + print("ERROR: you called a testcase declaration file as an executable module.") |
| 54 | + print("Use: 'python -m unitest <testcase module>'") |
| 55 | + exit(1) |
| 56 | + |
| 57 | + |
| 58 | +class Application(LineTerminal): |
| 59 | + def __init__(self): |
| 60 | + super().__init__(verbose=True, debug=True, quiet=False) |
| 61 | + |
| 62 | + LineTerminal.FATAL_EXIT_CODE = 0 |
| 63 | + |
| 64 | + |
| 65 | +class Terminal(TestCase): |
| 66 | + app : Application |
| 67 | + |
| 68 | + def setUp(self) -> None: |
| 69 | + self.app = Application() |
| 70 | + |
| 71 | + def test_Version(self): |
| 72 | + Application.versionCheck((3, 8, 0)) |
| 73 | + |
| 74 | + def test_Write(self): |
| 75 | + self.app.WriteQuiet("This is a quiet message.") |
| 76 | + self.app.WriteNormal("This is a normal message.") |
| 77 | + self.app.WriteInfo("This is a info message.") |
| 78 | + self.app.WriteDebug("This is a debug message.") |
| 79 | + self.app.WriteWarning("This is a warning message.") |
| 80 | + self.app.WriteError("This is an error message.") |
| 81 | + self.app.WriteFatal("This is a fatal message.", immediateExit=False) |
0 commit comments