def test__report_end_result__when_no_tests_run__reports_stats(): with StubPrint(): reporter = PyneStatSummaryReporter() printed_text.clear() reporter.report_end_result() expect(printed_text[0]).to_contain("Ran 0 tests")
def test__report_success__prints_test_description(): with StubPrint(): it_block = ItBlock(None, "Some it block description", None) reporter = PrintingReporter(PyneTreeReporter()) printed_text.clear() reporter.report_success(it_block, 0) expect(printed_text[0]).to_contain("Some it block description")
def test__report_enter_context__prints_context_description(): with StubPrint(): describe_block = DescribeBlock(None, "Some context description", None) reporter = PrintingReporter(PyneTreeReporter()) printed_text.clear() reporter.report_enter_context(describe_block) expect(printed_text[0]).to_contain("Some context description")
def test__report_pending__prints_a_dash(): with StubPrint(): reporter = PrintingReporter(PyneDotReporter()) it_block = ItBlock(None, None, None) printed_text.clear() reporter.report_pending(it_block) expect(printed_text[0]).to_be("-")
def test__report_failure__prints_an_x(): with StubPrint(): reporter = PyneDotReporter() it_block = ItBlock(None, None, None) printed_text.clear() reporter.report_failure(it_block, it_block, Exception("some exception"), 1000) expect(printed_text[0]).to_be("x")
def test__report_success__prints_a_dot(): with StubPrint(): reporter = PrintingReporter(PyneDotReporter()) it_block = ItBlock(None, None, None) printed_text.clear() reporter.report_success(it_block, 0) expect(printed_text[0]).to_be(".")
def test__report_failure__prints_test_description(): with StubPrint(): it_block = ItBlock(None, "Some it block description", None) reporter = PyneTreeReporter() printed_text.clear() reporter.report_failure(it_block, it_block, Exception("some exception"), 0) expect(printed_text[0]).to_contain("Some it block description")
def test__report_end_result__when_all_tests_passed__it_prints_stats(): with StubPrint(): reporter = PyneStatSummaryReporter() it_block = ItBlock(None, None, None) reporter.report_success(it_block, 1000) reporter.report_success(it_block, 500) printed_text.clear() reporter.report_end_result() expect(printed_text[0]).to_contain("2 passed in 1.50 seconds")
def test__report_enter_context__indents_based_on_tree_depth(): with StubPrint(): describe_block = DescribeBlock(None, "Some context description", None) reporter = PrintingReporter(PyneTreeReporter()) printed_text.clear() reporter.report_enter_context(describe_block) reporter.report_enter_context(describe_block) reporter.report_enter_context(describe_block) first_indent = printed_text[0].find("Some context") expect(printed_text[1].find("Some context")).to_be(first_indent + 2) expect(printed_text[2].find("Some context")).to_be(first_indent + 4)
def test__report_end_result__test_is_pending__reports_stats(): with StubPrint(): reporter = PrintingReporter(PyneStatSummaryReporter()) passing_it_block = ItBlock(None, None, None) pending_it_block = ItBlock(None, None, None, pending=True) reporter.report_success(passing_it_block, 1000) reporter.report_pending(pending_it_block) printed_text.clear() reporter.report_end_result() expect(printed_text[0]).to_contain("1 passed, 1 pending in 1.00 seconds")
def test__report_end_result__when_a_test_has_failed__it_prints_stats(): with StubPrint(): reporter = PrintingReporter(PyneStatSummaryReporter()) it_block = ItBlock(None, None, None) reporter.report_failure(it_block, it_block, Exception("some exception"), 1000) reporter.report_success(it_block, 500) reporter.report_success(it_block, 500) printed_text.clear() reporter.report_end_result() expect(printed_text[0]).to_contain("1 failed, 2 passed in 2.00 seconds")
def test__report_failure__indents_based_on_tree_depth(): with StubPrint(): describe_block = DescribeBlock(None, "Some context description", None) it_block = ItBlock(None, "Some it block description", None) reporter = PrintingReporter(PyneTreeReporter()) printed_text.clear() reporter.report_enter_context(describe_block) reporter.report_failure(it_block, it_block, Exception(), 0) reporter.report_enter_context(describe_block) reporter.report_failure(it_block, it_block, Exception(), 0) reporter.report_enter_context(describe_block) reporter.report_failure(it_block, it_block, Exception(), 0) first_index = printed_text[1].find("Some it") expect(printed_text[3].find("Some it")).to_be(first_index + 2) expect(printed_text[5].find("Some it")).to_be(first_index + 4)