cengal.unittest.behavior_stabilizer.versions.v_0.wrapper_for__unittest
1#!/usr/bin/env python 2# coding=utf-8 3 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space> 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18 19__all__ = ['UnittestTestCaseState', 'UnittestTestCaseWithState'] 20 21 22""" 23Module Docstring 24Docstrings: http://www.python.org/dev/peps/pep-0257/ 25""" 26 27__author__ = "ButenkoMS <gtalk@butenkoms.space>" 28__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>" 29__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ] 30__license__ = "Apache License, Version 2.0" 31__version__ = "4.4.1" 32__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>" 33__email__ = "gtalk@butenkoms.space" 34# __status__ = "Prototype" 35__status__ = "Development" 36# __status__ = "Production" 37 38 39 40from .behavior_stabilizer import * 41import unittest 42 43 44class UnittestTestCaseState(TestCaseState): 45 def is_loaded(self) -> bool: 46 if not self.loaded: 47 raise unittest.SkipTest(f'Test case state "{self.name}" is not loaded.') 48 49 50class UnittestTestCaseWithState(unittest.TestCase): 51 state: UnittestTestCaseState 52 53 def setUp(self): 54 self.state.current_test_id = self._testMethodName 55 56 def tearDown(self) -> None: 57 self.state.current_test_id = None
45class UnittestTestCaseState(TestCaseState): 46 def is_loaded(self) -> bool: 47 if not self.loaded: 48 raise unittest.SkipTest(f'Test case state "{self.name}" is not loaded.')
Inherited Members
- cengal.unittest.behavior_stabilizer.versions.v_0.behavior_stabilizer.TestCaseState
- TestCaseState
- name
- raise_exceptions
- call_stack_per_test
- expected_call_stack_per_test
- loaded
- content_file_name
- readable_content_file_name
- content_dir_rel
- content_full_file_name
- readable_content_full_file_name
- old_global_fake_result
- current_test_id
- call_stack
- expected_call_stack
- check_current_state_item
- check_state_item
- check_state_range
- check_current_state
- check_whole_state
- check_all_tests_state
- register_intro
- ri
- register_outro
- ro
- register_last_result
- rls
- register_last_exception
- rle
- try_to_load_expected_call_stack
- try_to_save_expected_call_stack
- prepare_readable_content
- register
- unregister
51class UnittestTestCaseWithState(unittest.TestCase): 52 state: UnittestTestCaseState 53 54 def setUp(self): 55 self.state.current_test_id = self._testMethodName 56 57 def tearDown(self) -> None: 58 self.state.current_test_id = None
A class whose instances are single test cases.
By default, the test code itself should be placed in a method named 'runTest'.
If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.
Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test's environment ('fixture') can be implemented by overriding the 'setUp' and 'tearDown' methods respectively.
If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.
When subclassing TestCase, you can set these attributes:
- failureException: determines which exception will be raised when the instance's assertion methods fail; test methods raising this exception will be deemed to have 'failed' rather than 'errored'.
- longMessage: determines whether long messages (including repr of objects used in assert methods) will be printed on failure in addition to any explicit message passed.
- maxDiff: sets the maximum length of a diff in failure messages by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.
Inherited Members
- unittest.case.TestCase
- TestCase
- failureException
- longMessage
- maxDiff
- addTypeEqualityFunc
- addCleanup
- addClassCleanup
- setUpClass
- tearDownClass
- countTestCases
- defaultTestResult
- shortDescription
- id
- subTest
- run
- doCleanups
- doClassCleanups
- debug
- skipTest
- fail
- assertFalse
- assertTrue
- assertRaises
- assertWarns
- assertLogs
- assertEqual
- assertNotEqual
- assertAlmostEqual
- assertNotAlmostEqual
- assertSequenceEqual
- assertListEqual
- assertTupleEqual
- assertSetEqual
- assertIn
- assertNotIn
- assertIs
- assertIsNot
- assertDictEqual
- assertDictContainsSubset
- assertCountEqual
- assertMultiLineEqual
- assertLess
- assertLessEqual
- assertGreater
- assertGreaterEqual
- assertIsNone
- assertIsNotNone
- assertIsInstance
- assertNotIsInstance
- assertRaisesRegex
- assertWarnsRegex
- assertRegex
- assertNotRegex
- failUnlessRaises
- failIf
- assertRaisesRegexp
- assertRegexpMatches
- assertNotRegexpMatches
- failUnlessEqual
- assertEquals
- failIfEqual
- assertNotEquals
- failUnlessAlmostEqual
- assertAlmostEquals
- failIfAlmostEqual
- assertNotAlmostEquals
- failUnless
- assert_