def test_flatten_tests_on_nested_suites(): @lcc.suite("My suite 1") class mysuite1: @lcc.test("Test 1") def test1(self): pass @lcc.suite("My suite 2") class mysuite2: @lcc.test("Test 2") def test2(self): pass @lcc.suite("My suite 3") class mysuite3: @lcc.test("Test 3") def test3(self): pass @lcc.suite("My suite 4") class mysuite4: @lcc.test("Test 4") def test4(self): pass suites = load_suites_from_classes([mysuite1, mysuite3]) tests = flatten_tests(suites) assert [t.name for t in tests] == ["test1", "test2", "test3", "test4"]
def test_find_suite_unknown(): @lcc.suite("My suite 1") class mysuite1: pass suites = load_suites_from_classes([mysuite1]) with pytest.raises(CannotFindTreeNode): find_suite(suites, "unknownsuite")
def test_find_test(): @lcc.suite("My suite 1") class mysuite1: @lcc.test("My test") def mytest(self): pass suites = load_suites_from_classes([mysuite1]) test = find_test(suites, "mysuite1.mytest") assert test.name == "mytest"
def test_find_suite_nested(): @lcc.suite("My suite 1") class mysuite1: @lcc.suite("My suite 2") class mysuite2: pass suites = load_suites_from_classes([mysuite1]) suite = find_suite(suites, "mysuite1.mysuite2") assert suite.name == "mysuite2"
def test_find_test_unknown(): @lcc.suite("My suite 1") class mysuite1: @lcc.test("My test") def mytest(self): pass suites = load_suites_from_classes([mysuite1]) with pytest.raises(CannotFindTreeNode): find_test(suites, "mysuite1.unknown")
def test_find_suite_top(): @lcc.suite("My suite 1") class mysuite1: pass @lcc.suite("My suite 2") class mysuite2: pass suites = load_suites_from_classes([mysuite1, mysuite2]) suite = find_suite(suites, "mysuite2") assert suite.name == "mysuite2"
def suites_sample(): @lcc.suite("suite1") class suite1: @lcc.test("Test 1") def suite1_test1(self, fixt_for_suite1): pass @lcc.test("Test 2") def suite1_test2(self, fixt_for_test3): pass @lcc.suite("suite2") class suite2: @lcc.test("Test 1") def suite2_test1(self, fixt_for_test2): pass return load_suites_from_classes([suite1, suite2])
def test_flatten_suites(): @lcc.suite("My suite 1") class mysuite1: @lcc.test("Test 1") def test1(self): pass @lcc.suite("My suite 2") class mysuite2: @lcc.test("Test 2") def test2(self): pass suites = load_suites_from_classes([mysuite1, mysuite2]) flattened_suites = flatten_suites(suites) assert [s.name for s in flattened_suites] == ["mysuite1", "mysuite2"]
def test_flatten_suites_on_nested_suites(): @lcc.suite("My suite 1") class mysuite1: @lcc.suite("My suite 2") class mysuite2: @lcc.test("Test") def test(self): pass @lcc.suite("My suite 3") class mysuite3: @lcc.suite("My suite 4") class mysuite4: @lcc.test("Test") def test(self): pass suites = load_suites_from_classes([mysuite1, mysuite3]) flattened_suites = flatten_suites(suites) assert [s.name for s in flattened_suites ] == ["mysuite1", "mysuite2", "mysuite3", "mysuite4"]
def _test_run_filter(suite_classes, filtr, expected_test_paths): suites = load_suites_from_classes(suite_classes) _test_filter(suites, filtr, expected_test_paths)