tests.ui_tests module#

Tests for the user interface.

class tests.ui_tests.FakeUIColorizedTestBase(*args, **kwargs)[source]#

Bases: TestCase

Base class for test cases requiring that colorized output is active.

abstract_class = True#
expect_color = True#
expected = 'Hello world you!'#
net = False#
setUp()[source]#

Force colorized_output to True.

tearDown()[source]#

Undo colorized_output configuration.

class tests.ui_tests.FakeUITest(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test case to allow doing uncolorized general UI tests.

abstract_class = False#
expect_color = False#
expected = 'Hello world you! ***'#
setUp()[source]#

Create dummy instances for the test and patch encounter_color.

tearDown()[source]#

Unpatch the encounter_color method.

test_flat_color()[source]#

Test using colors with defaulting in between.

test_no_color()[source]#

Test a string without any colors.

test_one_color()[source]#

Test a string using one color.

test_one_color_newline()[source]#

Test with trailing new line and one color.

test_stack_implicit_color()[source]#

Test using stacked colors without popping any.

test_stack_with_pop_color()[source]#

Test using stacked colors and just popping the latest color.

ui_class#

alias of UI

class tests.ui_tests.FakeUnixTest(*args, **kwargs)[source]#

Bases: FakeUIColorizedTestBase, FakeUITest

Test case to allow doing colorized Unix tests in any environment.

abstract_class = False#
ui_class#

alias of UnixUI

class tests.ui_tests.FakeWin32Test(*args, **kwargs)[source]#

Bases: FakeUIColorizedTestBase, FakeUITest

Test case to allow doing colorized Win32 tests in any environment.

This only patches the ctypes import in the terminal_interface_win32 module. As the Win32CtypesUI is using the std-streams from another import these will be unpatched.

abstract_class = False#
setUp()[source]#

Patch the ctypes import and initialize a stream and UI instance.

ui_class#

alias of Win32UI

class tests.ui_tests.FakeWin32UncolorizedTest(*args, **kwargs)[source]#

Bases: FakeWin32Test

Test case to allow doing uncolorized Win32 tests in any environment.

abstract_class = True#
expect_color = False#
expected = 'Hello world you! ***'#
exception tests.ui_tests.TestExceptionError[source]#

Bases: Exception

Test exception.

class tests.ui_tests.TestTerminalInput(methodName='runTest')[source]#

Bases: UITestCase

Terminal input tests.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

input_choice_output = 'question ([A]nswer 1, a[n]swer 2, an[s]wer 3): '#
testInput()[source]#
testInputChoiceCapital()[source]#
testInputChoiceDefault()[source]#
testInputChoiceIncorrectAnswer()[source]#
testInputChoiceNonCapital()[source]#
test_input_list_choice()[source]#

Test input_list_choice function.

test_input_yn()[source]#
class tests.ui_tests.TestTerminalOutput(methodName='runTest')[source]#

Bases: UITestCase

Terminal output tests.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

test_critical()[source]#
test_debug()[source]#
test_error()[source]#
test_exception()[source]#
test_exception_empty()[source]#
test_exception_tb()[source]#
test_log()[source]#
test_output()[source]#
test_outputlevels_logging()[source]#

Test logger with output levels.

test_stdout()[source]#
test_warning()[source]#
tests = [('debug', 10, '', ''), ('verbose', 18, '', ''), ('info', 20, '', 'info\n'), ('stdout', 16, 'stdout\n', ''), ('input', 25, '', 'input\n'), ('WARNING', 30, '', 'WARNING: WARNING\n'), ('ERROR', 40, '', 'ERROR: ERROR\n'), ('CRITICAL', 50, '', 'CRITICAL: CRITICAL\n')]#
class tests.ui_tests.TestTerminalOutputColorUnix(methodName='runTest')[source]#

Bases: UITestCase

Terminal output color tests.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

str1 = 'text <<lightpurple>>light purple text<<default>> text'#
str2 = 'normal text <<lightpurple>> light purple <<lightblue>> light blue <<previous>> light purple <<default>> normal text'#
testOutputColorCascade_incorrect()[source]#

Test incorrect behavior of testOutputColorCascade.

testOutputColorizedText()[source]#
testOutputNoncolorizedText()[source]#
class tests.ui_tests.TestTerminalUnicodeUnix(methodName='runTest')[source]#

Bases: UITestCase

Terminal output tests for Unix.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

testInputUnicodeText()[source]#
testOutputUnicodeText()[source]#
class tests.ui_tests.TestTransliterationTable(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test transliteration table.

abstract_class = False#
test_latin_digits()[source]#

Test that non latin digits are in transliteration table.

test_transliteration_table()[source]#

Test transliteration table consistency.

class tests.ui_tests.TestTransliterationUnix(methodName='runTest')[source]#

Bases: UITestCase

Terminal output transliteration tests.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

testOutputTransliteratedUnicodeText()[source]#
class tests.ui_tests.UITestCase(methodName='runTest')[source]#

Bases: TestCaseBase

UI tests.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

net = False#
setUp()[source]#

Setup test.

Here we patch standard input, output, and errors, essentially redirecting to StringIO streams.

tearDown()[source]#

Cleanup test.