Ejemplo n.º 1
0
def test__report_failure__prints_the_wrapped_reporter_failure_message():
    with StubPrint():
        reporter = PrintingReporter(PyneDotReporter())
        it_block = ItBlock(None, None, None)

        reporter.report_failure(it_block, it_block, Exception("some exception"), 1000)

        expect(printed_text[0]).to_be("x")
Ejemplo n.º 2
0
def test__report_pending__prints_test_description():
    with StubPrint():
        it_block = ItBlock(None, "Some it block description", None)
        reporter = PrintingReporter(PyneTreeReporter())

        reporter.report_pending(it_block)

        expect(printed_text[0]).to_contain("Some it block description")
Ejemplo n.º 3
0
def test__report_pending__prints_the_wrapped_reporter_pending_message():
    with StubPrint():
        reporter = PrintingReporter(PyneDotReporter())
        it_block = ItBlock(None, None, None)

        reporter.report_pending(it_block)

        expect(printed_text[0]).to_be("-")
Ejemplo n.º 4
0
def test__report_end_result__when_no_tests_run__reports_stats():
    with StubPrint():
        reporter = PrintingReporter(PyneStatSummaryReporter())

        printed_text.clear()

        reporter.report_end_result()

        expect(printed_text[0]).to_contain("Ran 0 tests")
Ejemplo n.º 5
0
def test__report_success__prints_the_wrapped_reporter_success_message():
    with StubPrint():
        reporter = PrintingReporter(PyneDotReporter())

        it_block = ItBlock(None, None, None)

        reporter.report_success(it_block, 0)

        expect(printed_text[0]).to_be(".")
Ejemplo n.º 6
0
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")
Ejemplo n.º 7
0
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("-")
Ejemplo n.º 8
0
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")
Ejemplo n.º 9
0
def test__report_failure__prints_an_x():
    with StubPrint():
        reporter = PrintingReporter(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")
Ejemplo n.º 10
0
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(".")
Ejemplo n.º 11
0
def reporter_factory():
    during_execution_reporters = (PrintingReporter(PyneTreeReporter()),
                                  PrintingReporter(PyneStatSummaryReporter()),
                                  PrintingReporter(
                                      PyneFailureSummaryReporter()))
    summary_reporters = (PrintingReporter(
        RecordForSummaryReporter(PyneTreeReporter())),
                         PrintingReporter(
                             RecordForSummaryReporter(
                                 PyneStatSummaryReporter())))

    return CompositeReporter(*during_execution_reporters, *summary_reporters,
                             ExceptionReporter())
Ejemplo n.º 12
0
def test__report_end_result__when_all_tests_passed__it_prints_stats():
    with StubPrint():
        reporter = PrintingReporter(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")
Ejemplo n.º 13
0
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")
Ejemplo n.º 14
0
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")
Ejemplo n.º 15
0
def test__report_end_result__when_test_had_assertion_error__includes_the_file_location():
    reporter = PrintingReporter(PyneFailureSummaryReporter())
    with StubPrint():
        exception = Exception()
        try:
            raise exception
        except Exception as e:
            block = ItBlock(None, None, None)
            reporter.report_failure(block, block, e, 0)
        reporter.report_end_result()

    expect(printed_text).to_contain(contains("reporters/pyne_failure_summary_reporter_test.py"))
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
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)