How to use run_suite_classes method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_runner.py

Source:test_runner.py Github

copy

Full Screen

...188 class suite_2:189 @lcc.test("test")190 def test(self):191 pass192 report = run_suite_classes((suite_1, suite_2))193 assert_test_statuses(report, disabled=["suite_1.test"], passed=["suite_2.test"])194 assert not marker195def test_setup_suite_with_disabled_test_and_force_disabled():196 marker = []197 @lcc.suite("suite_1")198 class suite_1:199 def setup_suite(self):200 marker.append("ok")201 @lcc.test("test")202 @lcc.disabled()203 def test(self):204 pass205 @lcc.suite("suite_2")206 class suite_2:207 @lcc.test("test")208 def test(self):209 pass210 report = run_suite_classes((suite_1, suite_2), force_disabled=True)211 assert_test_statuses(report, passed=["suite_1.test", "suite_2.test"])212 assert marker213def test_teardown_suite():214 marker = []215 @lcc.suite("MySuite")216 class MySuite:217 def teardown_suite(self):218 marker.append("ok")219 @lcc.test("Some test")220 def sometest(self):221 pass222 run_suite_class(MySuite)223 assert marker224def test_teardown_suite_with_disabled_test():225 marker = []226 @lcc.suite("suite_1")227 class suite_1:228 @lcc.test("test")229 @lcc.disabled()230 def test(self):231 pass232 def teardown_suite(self):233 marker.append("ok")234 @lcc.suite("suite_2")235 class suite_2:236 @lcc.test("test")237 def test(self):238 pass239 report = run_suite_classes((suite_1, suite_2))240 assert_test_statuses(report, disabled=["suite_1.test"], passed=["suite_2.test"])241 assert not marker242def test_teardown_suite_with_disabled_test_and_force_disabled():243 marker = []244 @lcc.suite("suite_1")245 class suite_1:246 @lcc.test("test")247 @lcc.disabled()248 def test(self):249 pass250 def teardown_suite(self):251 marker.append("ok")252 @lcc.suite("suite_2")253 class suite_2:254 @lcc.test("test")255 def test(self):256 pass257 report = run_suite_classes((suite_1, suite_2), force_disabled=True)258 assert_test_statuses(report, passed=["suite_1.test", "suite_2.test"])259 assert marker260def test_teardown_suite_after_test_failure():261 marker = []262 @lcc.suite("MySuite")263 class MySuite:264 def teardown_suite(self):265 marker.append("ok")266 @lcc.test("Some test")267 def sometest(self):268 1 / 0269 run_suite_class(MySuite)270 assert marker271def test_teardown_suite_after_test_failure_and_test_success():272 marker = []273 @lcc.suite("MySuite")274 class MySuite:275 def teardown_suite(self):276 marker.append("teardown_suite")277 @lcc.test("Test 1")278 def test_1(self):279 marker.append("test_1")280 1 / 0281 @lcc.test("Test 2")282 def test_2(self):283 marker.append("test_2")284 run_suite_class(MySuite)285 assert marker == ["test_1", "test_2", "teardown_suite"]286def test_setup_test_error():287 marker = []288 @lcc.suite("MySuite")289 class MySuite:290 def setup_test(self, test):291 1 / 0292 @lcc.test("Some test")293 def sometest(self):294 pass295 def teardown_test(self, test, status):296 marker.append(test)297 report = run_suite_class(MySuite)298 assert_test_failed(report)299 assert len(marker) == 0300def test_setup_test_error_in_fixture():301 @lcc.fixture()302 def fix():303 1 / 0304 @lcc.suite("MySuite")305 class MySuite:306 @lcc.test("Some test")307 def sometest(self, fix):308 pass309 assert_test_failed(run_suite_class(MySuite, fixtures=[fix]))310def test_teardown_test_error():311 @lcc.suite("MySuite")312 class MySuite:313 def teardown_test(self, test, status):314 1 / 0315 @lcc.test("Some test")316 def sometest(self):317 pass318 assert_test_failed(run_suite_class(MySuite))319def test_teardown_test_error_in_fixture():320 @lcc.fixture()321 def fix():322 1 / 0323 @lcc.suite("MySuite")324 class MySuite:325 @lcc.test("Some test")326 def sometest(self, fix):327 pass328 assert_test_failed(run_suite_class(MySuite, fixtures=[fix]))329def test_setup_suite_error_and_subsuite():330 @lcc.suite("MySuite")331 class MySuite:332 def setup_suite(self):333 1 / 0334 @lcc.test("test")335 def test(self):336 pass337 @lcc.suite("MySubSuite")338 class MySubSuite:339 @lcc.test("test")340 def test(self):341 pass342 assert_test_statuses(run_suite_class(MySuite), skipped=["MySuite.test"], passed=["MySuite.MySubSuite.test"])343def test_setup_suite_error_because_of_exception():344 marker = []345 @lcc.suite("MySuite")346 class MySuite:347 def setup_suite(self):348 1 / 0349 @lcc.test("Some test")350 def sometest(self):351 pass352 def teardown_suite(self):353 marker.append("suite_teardown")354 report = run_suite_class(MySuite)355 assert_test_skipped(report)356 assert not marker357def test_setup_suite_error_because_of_error_log():358 marker = []359 @lcc.suite("MySuite")360 class MySuite:361 def setup_suite(self):362 lcc.log_error("some error")363 @lcc.test("Some test")364 def sometest(self):365 pass366 def teardown_suite(self):367 marker.append("teardown")368 report = run_suite_class(MySuite)369 assert_test_skipped(report)370 assert not marker371def test_setup_suite_error_because_of_fixture():372 marker = []373 @lcc.fixture(scope="suite")374 def fix():375 1 / 0376 @lcc.suite("MySuite")377 class MySuite:378 @lcc.test("Some test")379 def sometest(self, fix):380 pass381 @lcc.test("Some other test")382 def sometest_bis(self):383 pass384 def teardown_suite(self):385 marker.append("must_not_be_executed")386 report = run_suite_class(MySuite, fixtures=[fix])387 assert_test_statuses(report, skipped=["MySuite.sometest", "MySuite.sometest_bis"])388 assert not marker389def test_teardown_suite_error_because_of_exception():390 @lcc.suite("MySuite")391 class MySuite:392 @lcc.test("Some test")393 def sometest(self):394 pass395 def teardown_suite(self):396 1 / 0397 report = run_suite_class(MySuite)398 assert_test_passed(report)399 assert_report_node_success(report, ReportLocation.in_suite_teardown("MySuite"), expected=False)400def test_teardown_suite_error_because_of_error_log():401 @lcc.suite("MySuite")402 class MySuite:403 @lcc.test("Some test")404 def sometest(self):405 pass406 def teardown_suite(self):407 lcc.log_error("some error")408 report = run_suite_class(MySuite)409 assert_test_passed(report)410 assert_report_node_success(report, ReportLocation.in_suite_teardown("MySuite"), expected=False)411def test_teardown_suite_error_because_of_fixture():412 marker = []413 @lcc.fixture(scope="suite")414 def fix():415 yield 2416 1 / 0417 @lcc.suite("MySuite")418 class MySuite:419 @lcc.test("Some test")420 def sometest(self, fix):421 pass422 def teardown_suite(self):423 marker.append("teardown")424 report = run_suite_class(MySuite, fixtures=[fix])425 assert_test_passed(report)426 assert_report_node_success(report, ReportLocation.in_suite_teardown("MySuite"), expected=False)427 assert len(marker) == 1428def test_setup_test_session_error_because_of_exception():429 @lcc.fixture(scope="session")430 def fixt():431 1 / 0432 @lcc.suite("MySuite")433 class MySuite:434 @lcc.test("Some test")435 def sometest(self, fixt):436 pass437 @lcc.test("Some other test")438 def sometest_bis(self):439 pass440 report = run_suite_class(MySuite, fixtures=[fixt])441 assert_test_statuses(report, skipped=["MySuite.sometest", "MySuite.sometest_bis"])442 assert_report_node_success(report, ReportLocation.in_test_session_setup(), expected=False)443 test_1, test_2 = list(report.all_tests())444 assert "test session setup failed" in test_1.status_details445 assert "test session setup failed" in test_2.status_details446def test_setup_test_session_error_and_setup_suite():447 marker = []448 @lcc.suite("MySuite")449 class MySuite:450 def setup_suite(self, fixt):451 marker.append("setup_suite")452 @lcc.test("Some test")453 def sometest(self):454 pass455 @lcc.fixture(scope="session")456 def fixt():457 1 / 0458 report = run_suite_class(MySuite, fixtures=[fixt])459 assert_test_skipped(report)460 assert_report_node_success(report, ReportLocation.in_test_session_setup(), expected=False)461 assert not marker462def test_teardown_test_session_error_because_of_exception():463 @lcc.fixture(scope="session")464 def fix():465 yield 1466 1 / 0467 @lcc.suite("MySuite")468 class MySuite:469 @lcc.test("Some test")470 def sometest(self, fix):471 pass472 @lcc.test("Some other test")473 def sometest_bis(self):474 pass475 report = run_suite_class(MySuite, fixtures=[fix])476 assert_test_statuses(report, passed=["MySuite.sometest", "MySuite.sometest_bis"])477 assert_report_node_success(report, ReportLocation.in_test_session_teardown(), expected=False)478def test_teardown_test_session_after_test_failure():479 marker = []480 @lcc.fixture(scope="session")481 def fixt():482 yield 1483 marker.append(1)484 @lcc.suite("MySuite")485 class MySuite:486 @lcc.test("Some test")487 def sometest(self, fixt):488 1 / 0489 run_suite_class(MySuite, fixtures=[fixt])490 assert marker491def test_teardown_test_session_after_test_failure_and_test_success():492 marker = []493 @lcc.fixture(scope="session")494 def fixt():495 marker.append("test_session_setup")496 yield 1497 marker.append("test_session_teardown")498 @lcc.suite("MySuite")499 class MySuite:500 @lcc.test("Test 1")501 def test_1(self, fixt):502 marker.append("test_1")503 1 / 0504 @lcc.test("Test 2")505 def test_2(self):506 marker.append("test_2")507 run_suite_class(MySuite, fixtures=[fixt])508 assert marker == ["test_session_setup", "test_1", "test_2", "test_session_teardown"]509def test_pre_run_fixture_exception():510 @lcc.fixture(scope="pre_run")511 def fix():512 1 / 0513 @lcc.suite("MySuite")514 class MySuite:515 @lcc.test("Some test")516 def sometest(self, fix):517 pass518 with pytest.raises(LemoncheesecakeException) as excinfo:519 report = run_suite_class(MySuite, fixtures=[fix])520 assert "Got an unexpected" in str(excinfo.value)521 assert_test_skipped(report)522def test_pre_run_fixture_user_error():523 @lcc.fixture(scope="pre_run")524 def fix():525 raise lcc.UserError("some error")526 @lcc.suite("MySuite")527 class MySuite:528 @lcc.test("Some test")529 def sometest(self, fix):530 pass531 with pytest.raises(LemoncheesecakeException) as excinfo:532 report = run_suite_class(MySuite, fixtures=[fix])533 assert str(excinfo.value) == "some error"534 assert_test_skipped(report)535def test_pre_run_fixture_teardown_exception():536 @lcc.fixture(scope="pre_run")537 def fix():538 yield539 1 / 0540 @lcc.suite("MySuite")541 class MySuite:542 @lcc.test("Some test")543 def sometest(self, fix):544 pass545 with pytest.raises(LemoncheesecakeException) as excinfo:546 report = run_suite_class(MySuite, fixtures=[fix])547 assert "Got an unexpected" in str(excinfo.value)548 assert_test_passed(report)549def test_pre_run_fixture_teardown_user_error():550 @lcc.fixture(scope="pre_run")551 def fix():552 yield553 raise lcc.UserError("some error")554 @lcc.suite("MySuite")555 class MySuite:556 @lcc.test("Some test")557 def sometest(self, fix):558 pass559 with pytest.raises(LemoncheesecakeException) as excinfo:560 report = run_suite_class(MySuite, fixtures=[fix])561 assert str(excinfo.value) == "some error"562 assert_test_passed(report)563def test_run_with_fixture_using_test_method():564 marker = []565 @lcc.fixture()566 def test_fixture():567 return 1568 @lcc.suite("MySuite")569 class MySuite:570 @lcc.test("Test")571 def test(self, test_fixture):572 marker.append(test_fixture)573 run_suite_class(MySuite, fixtures=[test_fixture])574 assert marker == [1]575def test_run_with_fixture_using_test_function():576 @lcc.fixture()577 def test_fixture():578 return 2579 suite = build_suite_from_module("""580@lcc.test("Test")581def test(test_fixture):582 lcc.log_info(str(test_fixture))583""")584 report = run_suite(suite, fixtures=[test_fixture])585 test = next(report.all_tests())586 assert test.get_steps()[0].get_logs()[0].message == "2"587def test_run_with_fixture_with_logs():588 marker = []589 @lcc.fixture()590 def test_fixture():591 lcc.log_info("setup")592 yield 1593 lcc.log_info("teardown")594 @lcc.suite("MySuite")595 class MySuite:596 @lcc.test("Test")597 def test(self, test_fixture):598 lcc.set_step("Doing some test")599 lcc.log_info("some log")600 marker.append(test_fixture)601 report = run_suite_class(MySuite, fixtures=[test_fixture])602 assert marker == [1]603 steps = report.get_suites()[0].get_tests()[0].get_steps()604 assert len(steps) == 3605 assert steps[0].description == "Setup test"606 assert steps[1].description == "Doing some test"607 assert steps[2].description == "Teardown test"608def test_run_with_fixtures_using_yield_and_dependencies():609 marker = []610 @lcc.fixture(scope="pre_run")611 def session_fixture_prerun():612 retval = 2613 marker.append(retval)614 yield retval615 marker.append(1)616 @lcc.fixture(scope="session")617 def session_fixture(session_fixture_prerun):618 lcc.log_info("session_fixture_setup")619 retval = session_fixture_prerun * 3620 marker.append(retval)621 yield retval622 marker.append(2)623 lcc.log_info("session_fixture_teardown")624 @lcc.fixture(scope="suite")625 def suite_fixture(session_fixture):626 lcc.log_info("suite_fixture_setup")627 retval = session_fixture * 4628 marker.append(retval)629 yield retval630 marker.append(3)631 lcc.log_info("suite_fixture_teardown")632 @lcc.fixture(scope="test")633 def test_fixture(suite_fixture):634 lcc.log_info("test_fixture_setup")635 retval = suite_fixture * 5636 marker.append(retval)637 yield retval638 marker.append(4)639 lcc.log_info("test_fixture_teardown")640 @lcc.suite("MySuite")641 class MySuite:642 @lcc.test("Test")643 def test(self, test_fixture):644 marker.append(test_fixture * 6)645 report = run_suite_class(MySuite, fixtures=(session_fixture_prerun, session_fixture, suite_fixture, test_fixture))646 # test that each fixture value is passed to test or fixture requiring the fixture647 assert marker == [2, 6, 24, 120, 720, 4, 3, 2, 1]648 # check that each fixture and fixture teardown is properly executed in the right scope649 assert report.test_session_setup.get_steps()[0].get_logs()[0].message == "session_fixture_setup"650 assert report.test_session_teardown.get_steps()[0].get_logs()[0].message == "session_fixture_teardown"651 assert report.get_suites()[0].suite_setup.get_steps()[0].get_logs()[0].message == "suite_fixture_setup"652 assert report.get_suites()[0].suite_teardown.get_steps()[0].get_logs()[0].message == "suite_fixture_teardown"653 assert report.get_suites()[0].get_tests()[0].get_steps()[0].get_logs()[0].message == "test_fixture_setup"654 assert report.get_suites()[0].get_tests()[0].get_steps()[1].get_logs()[0].message == "test_fixture_teardown"655def test_run_with_fixtures_dependencies_in_test_pre_run_scope():656 # in this test, fixture dependency is set on fixture alphabetical inverse657 # order to highlight a bad dependency check implementation that use set data type658 marker = []659 @lcc.fixture(names=["fixt_3"], scope="pre_run")660 def fixt3():661 return 2662 @lcc.fixture(names=["fixt_2"], scope="pre_run")663 def fixt2(fixt_3):664 return fixt_3 * 3665 @lcc.fixture(names=["fixt_1"], scope="pre_run")666 def fixt1(fixt_2):667 return fixt_2 * 4668 @lcc.suite("MySuite")669 class MySuite:670 @lcc.test("Test")671 def test(self, fixt_1):672 marker.append(fixt_1)673 run_suite_class(MySuite, fixtures=[fixt1, fixt2, fixt3])674 assert marker == [24]675def test_run_with_fixtures_dependencies_in_test_session_scope():676 # in this test, fixture dependency is set on fixture alphabetical inverse677 # order to highlight a bad dependency check implementation that use set data type678 marker = []679 @lcc.fixture(names=["fixt_3"], scope="session")680 def fixt3():681 return 2682 @lcc.fixture(names=["fixt_2"], scope="session")683 def fixt2(fixt_3):684 return fixt_3 * 3685 @lcc.fixture(names=["fixt_1"], scope="session")686 def fixt1(fixt_2):687 return fixt_2 * 4688 @lcc.suite("MySuite")689 class MySuite:690 @lcc.test("Test")691 def test(self, fixt_1):692 marker.append(fixt_1)693 run_suite_class(MySuite, fixtures=[fixt1, fixt2, fixt3])694 assert marker == [24]695def test_run_with_fixtures_dependencies_in_suite_scope():696 # in this test, fixture dependency is set on fixture alphabetical inverse697 # order to highlight a bad dependency check implementation that use set data type698 marker = []699 @lcc.fixture(names=["fixt_3"], scope="suite")700 def fixt3():701 return 2702 @lcc.fixture(names=["fixt_2"], scope="suite")703 def fixt2(fixt_3):704 return fixt_3 * 3705 @lcc.fixture(names=["fixt_1"], scope="suite")706 def fixt1(fixt_2):707 return fixt_2 * 4708 @lcc.suite("MySuite")709 class MySuite:710 @lcc.test("Test")711 def test(self, fixt_1):712 marker.append(fixt_1)713 run_suite_class(MySuite, fixtures=[fixt1, fixt2, fixt3])714 assert marker == [24]715def test_run_with_fixtures_dependencies_in_test_scope():716 # in this test, fixture dependency is set on fixture alphabetical inverse717 # order to highlight a bad dependency check implementation that use set data type718 marker = []719 @lcc.fixture(names=["fixt_3"], scope="test")720 def fixt3():721 return 2722 @lcc.fixture(names=["fixt_2"], scope="test")723 def fixt2(fixt_3):724 return fixt_3 * 3725 @lcc.fixture(names=["fixt_1"], scope="test")726 def fixt1(fixt_2):727 return fixt_2 * 4728 @lcc.suite("MySuite")729 class MySuite:730 @lcc.test("Test")731 def test(self, fixt_1):732 marker.append(fixt_1)733 run_suite_class(MySuite, fixtures=[fixt1, fixt2, fixt3])734 assert marker == [24]735def test_run_with_suite_fixture_used_in_subsuite():736 marker = []737 @lcc.fixture(scope="suite")738 def fixt1():739 yield 1740 marker.append(2)741 @lcc.suite("MySuiteA")742 class MySuiteA:743 @lcc.test("Test")744 def test(self, fixt1):745 marker.append(fixt1)746 @lcc.suite("MySuiteB")747 class MySuiteB:748 @lcc.test("Test")749 def test(self, fixt1):750 marker.append(fixt1)751 @lcc.suite("MySuiteC")752 class MySuiteC:753 @lcc.test("Test")754 def test(self, fixt1):755 marker.append(fixt1)756 run_suite_class(MySuiteA, fixtures=[fixt1])757 assert marker == [1, 2, 1, 2, 1, 2]758def test_run_with_fixture_used_in_setup_suite():759 marker = []760 @lcc.fixture(scope="suite")761 def fixt1():762 return 1763 @lcc.suite("MySuiteA")764 class MySuite:765 def setup_suite(self, fixt1):766 marker.append(fixt1)767 @lcc.test("sometest")768 def sometest(self):769 pass770 run_suite_class(MySuite, fixtures=[fixt1])771 assert marker == [1]772def test_run_with_fixture_injected_in_class():773 marker = []774 @lcc.fixture(scope="session")775 def fixt1():776 return 1777 @lcc.suite("MySuiteA")778 class MySuite:779 fixt1 = lcc.inject_fixture()780 @lcc.test("sometest")781 def sometest(self):782 marker.append(self.fixt1)783 report = run_suite_class(MySuite, fixtures=[fixt1])784 assert_test_passed(report)785 assert marker == [1]786def test_run_with_fixture_injected_in_class_and_fixture_name_arg():787 marker = []788 @lcc.fixture(scope="session")789 def fixt1():790 return 1791 @lcc.suite("MySuiteA")792 class MySuite:793 fxt = lcc.inject_fixture("fixt1")794 @lcc.test("sometest")795 def sometest(self):796 marker.append(self.fxt)797 report = run_suite_class(MySuite, fixtures=[fixt1])798 assert_test_passed(report)799 assert marker == [1]800def test_run_with_fixture_injected_in_module():801 @lcc.fixture(scope="suite")802 def fixt1():803 return "MARKER"804 suite = build_suite_from_module("""805fixt1 = lcc.inject_fixture()806@lcc.test("Some test")807def sometest():808 lcc.log_info(fixt1)809 """)810 report = run_suite(suite, fixtures=[fixt1])811 test = next(report.all_tests())812 assert test.get_steps()[0].get_logs()[0].message == "MARKER"813def test_run_with_fixture_per_thread():814 @lcc.fixture(scope="session", per_thread=True)815 def fixt():816 return object()817 witness = defaultdict(set)818 @lcc.suite()819 class Suite:820 @lcc.test()821 @lcc.parametrized({"value": value} for value in range(20)) # create 20 different tests822 def test(self, value, fixt):823 time.sleep(0.01) # make sure that each thread will be able to execute some tests824 witness[threading.current_thread().ident].add(fixt)825 run_suite_class(Suite, fixtures=(fixt,), nb_threads=4)826 # make sure that for each test-thread, the same fixture actual value is returned:827 assert len(witness) >= 1828 for objects in witness.values():829 assert len(objects) == 1830def test_run_with_fixture_per_thread_logging():831 @lcc.fixture(scope="session", per_thread=True)832 def fixt():833 lcc.log_info("Fixture setup")834 yield 1835 lcc.log_info("Fixture teardown")836 @lcc.suite()837 class Suite:838 @lcc.test()839 def test(self, fixt):840 pass841 report = run_suite_class(Suite, fixtures=(fixt,))842 test = get_last_test(report)843 assert test.get_steps()[0].get_logs()[0].message == "Fixture setup"844 assert report.test_session_teardown.get_steps()[0].get_logs()[0].message == "Fixture teardown"845def test_fixture_called_multiple_times():846 marker = []847 @lcc.fixture(scope="test")848 def fixt():849 return 1850 @lcc.suite("MySuite")851 class MySuite:852 @lcc.test("test 1")853 def test_1(self, fixt):854 marker.append(fixt)855 @lcc.test("test 2")856 def test_2(self, fixt):857 marker.append(fixt)858 run_suite_class(MySuite, fixtures=[fixt])859 assert marker == [1, 1]860def test_fixture_name_scopes():861 fixts = []862 @lcc.fixture(scope="session")863 def fixt_pre_run(fixture_name):864 fixts.append(fixture_name)865 @lcc.fixture(scope="session")866 def fixt_session(fixture_name, fixt_pre_run):867 fixts.append(fixture_name)868 @lcc.fixture(scope="suite")869 def fixt_suite(fixture_name, fixt_session):870 fixts.append(fixture_name)871 @lcc.fixture(scope="test")872 def fixt_test(fixture_name, fixt_suite):873 fixts.append(fixture_name)874 @lcc.suite("suite")875 class suite:876 @lcc.test("test")877 def test(self, fixt_test):878 pass879 run_suite_class(suite, fixtures=[fixt_pre_run, fixt_session, fixt_suite, fixt_test])880 assert fixts == ["fixt_pre_run", "fixt_session", "fixt_suite", "fixt_test"]881def test_fixture_name_multiple_names():882 fixts = []883 @lcc.fixture(scope="test", names=["fixt1", "fixt2"])884 def fixt(fixture_name):885 fixts.append(fixture_name)886 @lcc.suite("suite")887 class suite:888 @lcc.test("test")889 def test(self, fixt1, fixt2):890 pass891 run_suite_class(suite, fixtures=[fixt])892 assert sorted(fixts) == ["fixt1", "fixt2"]893def test_fixture_with_test_scope_on_disabled_test():894 marker = []895 @lcc.fixture(scope="test")896 def fixt():897 marker.append("i've been executed")898 @lcc.suite("suite")899 class suite:900 @lcc.test("test 1")901 @lcc.disabled()902 def test_1(self, fixt):903 pass904 @lcc.test("test 2")905 def test_2(self):906 pass907 report = run_suite_class(suite, fixtures=[fixt])908 assert_test_statuses(report, disabled=["suite.test_1"], passed=["suite.test_2"])909 assert not marker910def test_fixture_with_suite_scope_on_disabled_test():911 marker = []912 @lcc.fixture(scope="suite")913 def fixt():914 marker.append("i've been executed")915 @lcc.suite("suite")916 class suite:917 @lcc.test("test 1")918 @lcc.disabled()919 def test_1(self, fixt):920 pass921 @lcc.test("test 2")922 def test_2(self):923 pass924 report = run_suite_class(suite, fixtures=[fixt])925 assert_test_statuses(report, disabled=["suite.test_1"], passed=["suite.test_2"])926 assert not marker927def test_fixture_with_suite_scope_on_disabled_test_and_force_disabled():928 marker = []929 @lcc.fixture(scope="suite")930 def fixt():931 marker.append("i've been executed")932 @lcc.suite("suite")933 class suite:934 @lcc.test("test 1")935 @lcc.disabled()936 def test_1(self, fixt):937 pass938 @lcc.test("test 2")939 def test_2(self):940 pass941 report = run_suite_class(suite, fixtures=[fixt], force_disabled=True)942 assert_test_statuses(report, passed=["suite.test_1", "suite.test_2"])943 assert marker944def test_fixture_with_session_scope_on_disabled_test():945 marker = []946 @lcc.fixture(scope="session")947 def fixt():948 marker.append("i've been executed")949 @lcc.suite("suite")950 class suite:951 @lcc.test("test 1")952 @lcc.disabled()953 def test_1(self, fixt):954 pass955 @lcc.test("test 2")956 def test_2(self):957 pass958 report = run_suite_class(suite, fixtures=[fixt])959 assert_test_statuses(report, disabled=["suite.test_1"], passed=["suite.test_2"])960 assert not marker961def test_fixture_with_session_scope_on_disabled_test_and_force_disabled():962 marker = []963 @lcc.fixture(scope="session")964 def fixt():965 marker.append("i've been executed")966 @lcc.suite("suite")967 class suite:968 @lcc.test("test 1")969 @lcc.disabled()970 def test_1(self, fixt):971 pass972 @lcc.test("test 2")973 def test_2(self):974 pass975 report = run_suite_class(suite, fixtures=[fixt], force_disabled=True)976 assert_test_statuses(report, passed=["suite.test_1", "suite.test_2"])977 assert marker978def test_fixture_with_pre_run_scope_on_disabled_test():979 marker = []980 @lcc.fixture(scope="pre_run")981 def fixt():982 marker.append("i've been executed")983 @lcc.suite("suite")984 class suite:985 @lcc.test("test 1")986 @lcc.disabled()987 def test_1(self, fixt):988 pass989 @lcc.test("test 2")990 def test_2(self):991 pass992 report = run_suite_class(suite, fixtures=[fixt])993 assert_test_statuses(report, disabled=["suite.test_1"], passed=["suite.test_2"])994 assert not marker995def test_fixture_with_pre_run_scope_on_disabled_test_and_force_disabled():996 marker = []997 @lcc.fixture(scope="pre_run")998 def fixt():999 marker.append("i've been executed")1000 @lcc.suite("suite")1001 class suite:1002 @lcc.test("test 1")1003 @lcc.disabled()1004 def test_1(self, fixt):1005 pass1006 @lcc.test("test 2")1007 def test_2(self):1008 pass1009 report = run_suite_class(suite, fixtures=[fixt], force_disabled=True)1010 assert_test_statuses(report, passed=["suite.test_1", "suite.test_2"])1011 assert marker1012def test_fixture_in_suite_with_disabled_test():1013 marker = []1014 @lcc.fixture(scope="suite")1015 def fixt():1016 marker.append("i've been executed")1017 @lcc.suite("suite_1")1018 class suite_1:1019 fixt = lcc.inject_fixture()1020 @lcc.test("test")1021 @lcc.disabled()1022 def test(self, fixt):1023 pass1024 @lcc.suite("suite_2")1025 class suite_2:1026 @lcc.test("test")1027 def test(self):1028 pass1029 report = run_suite_classes((suite_1, suite_2), fixtures=[fixt])1030 assert_test_statuses(report, disabled=["suite_1.test"], passed=["suite_2.test"])1031 assert not marker1032def test_fixture_in_suite_with_disabled_test_and_force_disabled():1033 marker = []1034 @lcc.fixture(scope="suite")1035 def fixt():1036 marker.append("i've been executed")1037 @lcc.suite("suite_1")1038 class suite_1:1039 fixt = lcc.inject_fixture()1040 @lcc.test("test")1041 @lcc.disabled()1042 def test(self, fixt):1043 pass1044 @lcc.suite("suite_2")1045 class suite_2:1046 @lcc.test("test")1047 def test(self):1048 pass1049 report = run_suite_classes((suite_1, suite_2), fixtures=[fixt], force_disabled=True)1050 assert_test_statuses(report, passed=["suite_1.test", "suite_2.test"])1051 assert marker1052def test_fixture_evaluation_order():1053 @lcc.fixture()1054 def a():1055 lcc.log_info("a")1056 @lcc.fixture()1057 def b():1058 lcc.log_info("b")1059 @lcc.fixture()1060 def c(b):1061 lcc.log_info("c")1062 @lcc.suite()1063 class suite:1064 @lcc.test()1065 def test(self, a, c):1066 pass1067 report = run_suite_class(suite, fixtures=(a, b, c))1068 test = get_last_test(report)1069 assert [e.message for e in test.get_steps()[0].get_logs()] == ["a", "b", "c"]1070def test_parametrized_simple():1071 @lcc.suite("suite")1072 class suite:1073 @lcc.test("test")1074 @lcc.parametrized([{"value": "foo"}])1075 def test(self, value):1076 lcc.log_info(value)1077 report = run_suite_class(suite)1078 test = get_last_test(report)1079 assert test.name == "test_1"1080 assert test.description == "test #1"1081 log = get_last_log(report)1082 assert log.message == "foo"1083def test_parametrized_with_multiple_test_and_fixture():1084 @lcc.fixture(scope="session")1085 def fixt():1086 return "something"1087 @lcc.suite("suite")1088 class suite:1089 @lcc.test("test")1090 @lcc.parametrized([{"value_1": "foo", "value_2": "bar"}, {"value_1": "baz", "value_2": "foo"}])1091 def test(self, value_1, value_2, fixt):1092 lcc.log_info(value_1)1093 lcc.log_info(value_2)1094 lcc.log_info(fixt)1095 report = run_suite_class(suite, fixtures=[fixt])1096 test_1, test_2 = report.all_tests()1097 assert test_1.name == "test_1"1098 assert test_1.description == "test #1"1099 assert test_1.get_steps()[0].get_logs()[0].message == "foo"1100 assert test_1.get_steps()[0].get_logs()[1].message == "bar"1101 assert test_1.get_steps()[0].get_logs()[2].message == "something"1102 assert test_2.name == "test_2"1103 assert test_2.description == "test #2"1104 assert test_2.get_steps()[0].get_logs()[0].message == "baz"1105 assert test_2.get_steps()[0].get_logs()[1].message == "foo"1106 assert test_2.get_steps()[0].get_logs()[2].message == "something"1107def test_parametrized_extra_param():1108 @lcc.suite("suite")1109 class suite:1110 @lcc.test("test")1111 @lcc.parametrized([{"value": "foo", "extra": "bar"}])1112 def test(self, value):1113 lcc.log_info(value)1114 report = run_suite_class(suite)1115 test = get_last_test(report)1116 assert test.name == "test_1"1117 assert test.description == "test #1"1118 log = get_last_log(report)1119 assert log.message == "foo"1120def test_stop_on_failure_test():1121 @lcc.suite("Suite")1122 class suite:1123 @lcc.test("Test 1")1124 def test1(self):1125 1 / 01126 1127 @lcc.test("Test 2")1128 def test2(self):1129 pass1130 report = run_suite_class(suite, stop_on_failure=True)1131 assert_test_statuses(report, failed=["suite.test1"], skipped=["suite.test2"])1132def test_stop_on_failure_suite_setup():1133 @lcc.suite("Suite 1")1134 class suite1:1135 def setup_suite(self):1136 1 / 01137 1138 @lcc.test("Test 1")1139 def test1(self):1140 pass1141 1142 @lcc.suite("Suite 2")1143 class suite2:1144 @lcc.test("Test 2")1145 def test2(self):1146 pass1147 report = run_suite_classes([suite1, suite2], stop_on_failure=True)1148 assert_test_statuses(report, skipped=["suite1.test1", "suite2.test2"])1149def test_stop_on_failure_suite_teardown():1150 @lcc.suite("Suite 1")1151 class suite1:1152 @lcc.test("Test 1")1153 def test1(self):1154 pass1155 def teardown_suite(self):1156 1 / 01157 1158 @lcc.suite("Suite 2")1159 class suite2:1160 @lcc.test("Test 2")1161 def test2(self):1162 pass1163 report = run_suite_classes([suite1, suite2], stop_on_failure=True)1164 assert_test_statuses(report, passed=["suite1.test1"], skipped=["suite2.test2"])1165def test_disabled_test():1166 @lcc.suite("Suite")1167 class mysuite:1168 @lcc.test("Test")1169 @lcc.disabled()1170 def mytest(self):1171 pass1172 report = run_suite_class(mysuite)1173 assert_test_statuses(report, disabled=["mysuite.mytest"])1174def test_disabled_test_with_reason():1175 @lcc.suite("Suite")1176 class mysuite:1177 @lcc.test("Test")...

Full Screen

Full Screen

test_report_writer.py

Source:test_report_writer.py Github

copy

Full Screen

...102 pass103 @lcc.test("Some test 3")104 def test_3_3(self):105 pass106 report = run_suite_classes([mysuite1, mysuite2])107 assert_report_from_suites(report, [mysuite1, mysuite2])108def test_check_success():109 @lcc.suite("MySuite")110 class mysuite:111 @lcc.test("Test 1")112 def test_1(self):113 check_that("somevalue", "foo", equal_to("foo"))114 report = run_suite_class(mysuite)115 test = get_last_test(report)116 assert test.status == "passed"117 step = test.get_steps()[0]118 assert "somevalue" in step.get_logs()[0].description119 assert "foo" in step.get_logs()[0].description120 assert step.get_logs()[0].is_successful is True...

Full Screen

Full Screen

reporttests.py

Source:reporttests.py Github

copy

Full Screen

...344class ReportSerializationTests(ReportingSessionTests):345 def do_test_reporting_session(self, suites, fixtures=(), report_saving_strategy=None, nb_threads=1):346 if type(suites) not in (list, tuple):347 suites = [suites]348 report = run_suite_classes(349 suites, fixtures=fixtures, backends=(self.backend,), tmpdir=".",350 report_saving_strategy=report_saving_strategy, nb_threads=nb_threads351 )352 unserialized_report = self.backend.load_report(self.backend.get_report_filename())353 assert_report(unserialized_report, report)354 def do_test_report_serialization(self, report):355 self.backend.save_report("report", report)356 unserialized_report = self.backend.load_report("report")357 assert_report(unserialized_report, report)358 def test_report_title(self):359 report = Report()360 report.title = "Report Title"361 report.start_time = time.time()362 report.end_time = report.start_time...

Full Screen

Full Screen

test_report_reportportal.py

Source:test_report_reportportal.py Github

copy

Full Screen

...140 def do_test_reporting_session(self, suites, fixtures=(), report_saving_strategy=None, nb_threads=1):141 if type(suites) not in (list, tuple):142 suites = [suites]143 with env_vars(LCC_RP_URL="http://localhost", LCC_RP_AUTH_TOKEN="sometoken", LCC_RP_PROJECT="myproj"):144 report = run_suite_classes(145 suites, backends=[ReportPortalBackend()], fixtures=fixtures, tmpdir=".", nb_threads=nb_threads146 )147 assert_rp_calls(148 reportportal_client.ReportPortalServiceAsync.return_value.mock_calls,149 list(report_to_rp_calls(report))150 )151 def test_create_reporting_session_with_only_required_parameters():152 _test_reporting_session(153 LCC_RP_URL="http://localhost", LCC_RP_AUTH_TOKEN="sometoken",154 LCC_RP_PROJECT="myproj",155 LCC_RP_LAUNCH_NAME=None, LCC_RP_LAUNCH_DESCRIPTION=None156 )157 def test_create_reporting_session_with_all_parameters():158 _test_reporting_session(...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful