def test_setup_suite_error_because_of_fixture(): marker = [] @lcc.fixture(scope="suite") def fix(): 1 / 0 @lcc.suite("MySuite") class MySuite: @lcc.test("Some test") def sometest(self, fix): pass @lcc.test("Some other test") def sometest_bis(self): pass def teardown_suite(self): marker.append("must_not_be_executed") report = run_suite_class(MySuite, fixtures=[fix]) assert_test_statuses(report, skipped=["MySuite.sometest", "MySuite.sometest_bis"]) assert not marker
def test_exception_abortsuite(): @lcc.suite("MySuite") class MySuite: @lcc.suite("MyFirstSuite") class MyFirstSuite: @lcc.test("Some test") def sometest(self): raise lcc.AbortSuite("test error") @lcc.test("Some other test") def someothertest(self): pass @lcc.suite("MySecondSuite") class MySecondSuite: @lcc.test("Another test") def anothertest(self): pass assert_test_statuses( run_suite_class(MySuite), failed=["MySuite.MyFirstSuite.sometest"], skipped=["MySuite.MyFirstSuite.someothertest"], passed=["MySuite.MySecondSuite.anothertest"], )
def test_disabled_test_with_force_disabled(): @lcc.suite("Suite") class mysuite: @lcc.test("Test") @lcc.disabled() def mytest(self): pass report = run_suite_class(mysuite, force_disabled=True) assert_test_statuses(report, passed=["mysuite.mytest"])
def test_exception_aborttest(): @lcc.suite("MySuite") class MySuite: @lcc.test("Some test") def sometest(self): raise lcc.AbortTest("test error") @lcc.test("Some other test") def someothertest(self): pass assert_test_statuses(run_suite_class(MySuite), failed=["MySuite.sometest"], passed=["MySuite.someothertest"])
def test_exception_unexpected(): @lcc.suite("MySuite") class MySuite: @lcc.test("First test") def first_test(self): 1 / 0 @lcc.test("Second test") def second_test(self): pass assert_test_statuses(run_suite_class(MySuite), failed=["MySuite.first_test"], passed=["MySuite.second_test"])
def test_depends_on_passed(): @lcc.suite("s") class suite: @lcc.test("t1") def test1(self): pass @lcc.test("t2") @lcc.depends_on("suite.test1") def test2(self): pass report = run_suite_class(suite) assert_test_statuses(report, passed=["suite.test1", "suite.test2"])
def test_disabled_suite(): @lcc.suite("Suite") @lcc.disabled() class mysuite: @lcc.test("Test 1") def test1(self): pass @lcc.test("Test 2") def test2(self): pass report = run_suite_class(mysuite) assert_test_statuses(report, disabled=["mysuite.test1", "mysuite.test2"])
def test_stop_on_failure_test(): @lcc.suite("Suite") class suite: @lcc.test("Test 1") def test1(self): 1 / 0 @lcc.test("Test 2") def test2(self): pass report = run_suite_class(suite, stop_on_failure=True) assert_test_statuses(report, failed=["suite.test1"], skipped=["suite.test2"])
def test_setup_suite_error_and_subsuite(): @lcc.suite("MySuite") class MySuite: def setup_suite(self): 1 / 0 @lcc.test("test") def test(self): pass @lcc.suite("MySubSuite") class MySubSuite: @lcc.test("test") def test(self): pass assert_test_statuses(run_suite_class(MySuite), skipped=["MySuite.test"], passed=["MySuite.MySubSuite.test"])
def test_depends_on_failed_and_subsuite(): @lcc.suite("s1") class suite1: @lcc.test("t1") def test1(self): lcc.log_error("some error") @lcc.suite("s2") class suite2: @lcc.test("t2") @lcc.depends_on("suite1.test1") def test2(self): pass report = run_suite_class(suite1) assert_test_statuses(report, failed=["suite1.test1"], skipped=["suite1.suite2.test2"])
def test_stop_on_failure_suite_setup(): @lcc.suite("Suite 1") class suite1: def setup_suite(self): 1 / 0 @lcc.test("Test 1") def test1(self): pass @lcc.suite("Suite 2") class suite2: @lcc.test("Test 2") def test2(self): pass report = run_suite_classes([suite1, suite2], stop_on_failure=True) assert_test_statuses(report, skipped=["suite1.test1", "suite2.test2"])
def test_bug_in_task_handling(): @lcc.suite("suite") class suite: @lcc.test("test 1") def test_1(self): lcc.log_error("error") @lcc.test("test 2") def test_2(self): lcc.log_error("error") @lcc.test("test 3") def test_3(self): pass report = run_suite_class(suite) assert_test_statuses(report, failed=["suite.test_1", "suite.test_2"], passed=["suite.test_3"])
def test_setup_test_session_error_because_of_exception(): @lcc.fixture(scope="session") def fixt(): 1 / 0 @lcc.suite("MySuite") class MySuite: @lcc.test("Some test") def sometest(self, fixt): pass @lcc.test("Some other test") def sometest_bis(self): pass report = run_suite_class(MySuite, fixtures=[fixt]) assert_test_statuses(report, skipped=["MySuite.sometest", "MySuite.sometest_bis"]) assert_report_node_success(report, TreeLocation.in_test_session_setup(), expected=False)
def test_depends_on_skipped(): @lcc.suite("s") class suite: @lcc.test("t1") def test1(self): lcc.log_error("some error") @lcc.test("t2") @lcc.depends_on("suite.test1") def test2(self): pass @lcc.test("t3") @lcc.depends_on("suite.test2") def test3(self): pass report = run_suite_class(suite) assert_test_statuses(report, failed=["suite.test1"], skipped=["suite.test2", "suite.test3"])
def test_depends_on_failed_exception(): @lcc.suite("s") class suite: @lcc.test("t1") def test1(self): raise Exception() @lcc.test("t2") @lcc.depends_on("suite.test1") def test2(self): pass @lcc.test("t3") def test3(self): pass report = run_suite_class(suite) assert_test_statuses(report, failed=["suite.test1"], skipped=["suite.test2"], passed=["suite.test3"])