esptest.testcase.unittest_case module
Glue between unittest.TestCase and XunitLogger.
This module has no dependency on pytest, so the base class works both under a
plain unittest runner and under pytest.
- esptest.testcase.unittest_case.get_case_result_from_outcome(test_case)[source]
Read pass/fail and a brief message for the current test method.
Meant to be called from
tearDownand works with both runners, whose outcome objects differ:unittest’s
_Outcomekeeps(test, exc_info)tuples on.errors, populated beforetearDownruns (result.failuresis only filled in afterwards, so it cannot be relied on here).pytest keeps an
ExceptionInfolist on_outcome.result._excinfo.
Returns
(passed, message);messageis empty when the case passed.
- class esptest.testcase.unittest_case.EspTestCase(methodName='runTest')[source]
Bases:
TestCaseA
unittest.TestCasethat streams results into an xUnit report.Subclasses only need to set
xunit_log_dir(and optionallytarget/config/xunit_suite_name) and write plaintest_*methods. Each case is opened insetUp()and closed intearDown()with the result derived from the runner outcome.Under pytest, the
bind_case_contextfixture fromesptest.pytest_plugincan injecttarget/config/xunit_log_dironto the class automatically.To fold several classes (or a whole pytest session) into a single report, assign a shared
XunitLoggertoxunit_loggerbeforesetUpClass()runs; the class then reuses that logger and does not close it (the owner is responsible for that).- xunit_logger: XunitLogger | None = None
the logger; created in
setUpClass(), or set externally to share one
- classmethod setUpClass()[source]
Hook method for setting up class fixture before running tests in the class.
- Return type:
None
- classmethod tearDownClass()[source]
Hook method for deconstructing the class fixture after running all tests in the class.
- Return type:
None