Esempio n. 1
0
def _replay_suite_events(suite, eventmgr):
    # type: (SuiteResult, BaseEventManager) -> None

    eventmgr.fire(events.SuiteStartEvent(suite, suite.start_time))

    if suite.suite_setup:
        eventmgr.fire(
            events.SuiteSetupStartEvent(suite, suite.suite_setup.start_time))
        _replay_steps_events(TreeLocation.in_suite_setup(suite),
                             suite.suite_setup.steps, eventmgr)
        if suite.suite_setup.end_time:
            eventmgr.fire(
                events.SuiteSetupEndEvent(suite, suite.suite_setup.end_time))

    for test in suite.get_tests():
        _replay_test_events(test, eventmgr)

    for sub_suite in suite.get_suites():
        _replay_suite_events(sub_suite, eventmgr)

    if suite.suite_teardown:
        eventmgr.fire(
            events.SuiteTeardownStartEvent(suite,
                                           suite.suite_teardown.start_time))
        _replay_steps_events(TreeLocation.in_suite_teardown(suite),
                             suite.suite_teardown.steps, eventmgr)
        if suite.suite_teardown.end_time:
            eventmgr.fire(
                events.SuiteTeardownEndEvent(suite,
                                             suite.suite_teardown.end_time))

    if suite.end_time:
        eventmgr.fire(events.SuiteEndEvent(suite, suite.end_time))
Esempio n. 2
0
 def run(self, context):
     if any(self.suite_setup_task.teardown_funcs):
         # before actual teardown
         context.event_manager.fire(events.SuiteTeardownStartEvent(self.suite))
         set_runtime_location(TreeLocation.in_suite_teardown(self.suite))
         set_step("Teardown suite")
         # actual teardown
         context.run_teardown_funcs(self.suite_setup_task.teardown_funcs)
         # after actual teardown
         context.event_manager.fire(events.SuiteTeardownEndEvent(self.suite))
Esempio n. 3
0
def test_teardown_suite_error_because_of_error_log():
    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self):
            pass

        def teardown_suite(self):
            lcc.log_error("some error")

    report = run_suite_class(MySuite)

    assert_test_passed(report)
    assert_report_node_success(report,
                               TreeLocation.in_suite_teardown("MySuite"),
                               expected=False)
Esempio n. 4
0
def test_teardown_suite_error_because_of_fixture():
    marker = []

    @lcc.fixture(scope="suite")
    def fix():
        yield 2
        1 / 0

    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self, fix):
            pass

        def teardown_suite(self):
            marker.append("teardown")

    report = run_suite_class(MySuite, fixtures=[fix])

    assert_test_passed(report)
    assert_report_node_success(report,
                               TreeLocation.in_suite_teardown("MySuite"),
                               expected=False)
    assert len(marker) == 1