コード例 #1
0
def test__fit__flags_the_it_block_as_focused():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    fit(some_method)
    expect(current_describe.it_blocks[0].focused).to_be(True)
コード例 #2
0
ファイル: pyne_tree_reporter_test.py プロジェクト: Avvir/pyne
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")
コード例 #3
0
def test__report_enter_context__increases_depth():
    reporter = PyneStatSummaryReporter()

    describe_block = DescribeBlock(None, None, None)

    reporter.report_enter_context(describe_block)
    expect(reporter.depth).to_be(1)

    reporter.report_enter_context(describe_block)
    expect(reporter.depth).to_be(2)
コード例 #4
0
def test__fdescribe__adds_a_describe_block_to_current_describe():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    fdescribe("some context")(some_method)
    expect(current_describe.describe_blocks).to_have_length(1)
    expect(current_describe.describe_blocks[0].method).to_be(some_method)
コード例 #5
0
def test__it__adds_it_block_to_current_describe():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    it(some_method)
    expect(current_describe.it_blocks).to_have_length(1)
    expect(current_describe.it_blocks[0].method).to_be(some_method)
コード例 #6
0
def test__it__when_using_string_description__sets_the_description():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    it("some cool thing happens")(some_method)

    expect(current_describe.it_blocks[0].description).to_be("some cool thing happens")
コード例 #7
0
def test__describe__when_using_string_description__sets_description():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    describe("some awesome description")(some_method)

    expect(current_describe.describe_blocks[0].description).to_be("some awesome description")
コード例 #8
0
def test__after_each__adds_after_each_block_to_current_describe():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    after_each(some_method)
    expect(current_describe.after_each_blocks).to_have_length(1)
    expect(current_describe.after_each_blocks[0].method).to_be(some_method)
    expect(current_describe.after_each_blocks[0].description).to_be("@after_each")
コード例 #9
0
def test__it__when_using_string_description__adds_it_block_to_describe():
    current_describe = DescribeBlock(None, None, None)
    test_collection.current_describe = current_describe

    def some_method():
        pass

    it("some it name")(some_method)

    expect(current_describe.it_blocks).to_have_length(1)
    expect(current_describe.it_blocks[0].method).to_be(some_method)
コード例 #10
0
ファイル: pyne_tree_reporter_test.py プロジェクト: Avvir/pyne
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)
コード例 #11
0
ファイル: pyne_test_collector.py プロジェクト: Avvir/pyne
def describe(method_or_description):
    if isinstance(method_or_description, str):
        description = method_or_description

        def named_describe(method):
            test_collection.current_describe.describe_blocks.append(
                    DescribeBlock(test_collection.current_describe, description, method))

        return named_describe
    else:
        method = method_or_description
        test_collection.current_describe.describe_blocks.append(
                DescribeBlock(test_collection.current_describe, method.__name__, method))
        return method_or_description
コード例 #12
0
ファイル: pyne_tree_reporter_test.py プロジェクト: Avvir/pyne
def test__report_pending__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())

        reporter.report_enter_context(describe_block)
        reporter.report_pending(it_block)

        reporter.report_enter_context(describe_block)
        reporter.report_pending(it_block)

        reporter.report_enter_context(describe_block)
        reporter.report_pending(it_block)

        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)
コード例 #13
0
def test__reset__sets_stats_to_0():
    describe_block = DescribeBlock(None, None, None)
    it_block = ItBlock(None, None, None)
    reporter = PyneStatSummaryReporter()
    reporter.report_enter_context(describe_block)
    reporter.report_enter_context(describe_block)
    reporter.report_success(it_block, 1000)
    reporter.report_failure(it_block, it_block, Exception("some exception"), 1000)
    reporter.report_failure(it_block, it_block, Exception("some exception"), 1000)

    reporter.reset()

    expect(reporter.stats.pass_count).to_be(0)
    expect(reporter.stats.is_failure).to_be(False)
    expect(reporter.stats.total_timing_millis).to_be(0)
    expect(reporter.stats.failure_count).to_be(0)
    expect(reporter.stats.test_count).to_be(0)
    expect(reporter.depth).to_be(0)
コード例 #14
0
def test__collect_describe__adds_children_to_the_describe():
    def describe_block_method():
        @describe
        def when_something_happens():
            pass

        @it
        def does_something():
            pass

        @before_each
        def do():
            pass

    describe_block = DescribeBlock(None, None, describe_block_method)

    test_collection.collect_describe(describe_block)

    expect(describe_block.before_each_blocks).to_have_length(1)
    expect(describe_block.describe_blocks).to_have_length(1)
    expect(describe_block.it_blocks).to_have_length(1)
コード例 #15
0
def test__collect_describe__when_there_are_nested_describes__collects_them():
    def describe_block_method():
        @describe
        def when_something_happens():
            @before_each
            def do():
                pass

            @it
            def does_something():
                pass

            @describe
            def when_something_is_true():
                pass

    describe_block = DescribeBlock(None, None, describe_block_method)

    test_collection.collect_describe(describe_block)

    expect(describe_block.describe_blocks[0].before_each_blocks).to_have_length(1)
    expect(describe_block.describe_blocks[0].describe_blocks).to_have_length(1)
    expect(describe_block.describe_blocks[0].it_blocks).to_have_length(1)
コード例 #16
0
ファイル: pyne_test_runner_test.py プロジェクト: Avvir/pyne
def test__when_a_describe_block_with_nested_describes_is_pended__it_reports_the_contained_tests_as_pending(
):
    reset()

    describe_block = DescribeBlock(None, "some describe", None, pending=True)
    inner_describe = DescribeBlock(describe_block, "some inner description",
                                   None)
    describe_block.describe_blocks = [inner_describe]

    def it1(self):
        pass

    inner_describe.it_blocks = [ItBlock(describe_block, "some test", it1)]

    reporter = StatTrackingReporter()
    run_tests(describe_block, reporter)

    expect(reporter.stats.test_count).to_be(1)
    expect(reporter.stats.pending_count).to_be(1)
コード例 #17
0
ファイル: pyne_test_collector.py プロジェクト: Avvir/pyne
 def named_describe(method):
     test_collection.current_describe.describe_blocks.append(
             DescribeBlock(test_collection.current_describe, description, method))
コード例 #18
0
ファイル: pyne_test_collector.py プロジェクト: Avvir/pyne
 def __init__(self):
     self.top_level_describe = DescribeBlock(None, "All Tests", no_tests)
     self.current_describe = self.top_level_describe
コード例 #19
0
ファイル: pyne_test_runner_test.py プロジェクト: Avvir/pyne
def test__when_a_describe_block_has_focused_descendants__it_runs_only_the_focused_tests(
):
    reset()

    describe_block = DescribeBlock(None, "some describe", None)
    inner_describe = DescribeBlock(describe_block, "some inner description",
                                   None)
    other_inner_describe = DescribeBlock(describe_block,
                                         "some other inner description", None)
    describe_block.describe_blocks = [inner_describe, other_inner_describe]

    def it1(self):
        pass

    inner_describe.it_blocks = [
        ItBlock(describe_block, "some test", it1, focused=True),
        ItBlock(describe_block, "some test", it1)
    ]
    describe_block.has_focused_descendants = True
    inner_describe.has_focused_descendants = True

    other_inner_describe.it_blocks = [
        ItBlock(describe_block, "some other test", it1),
        ItBlock(describe_block, "some third test", it1)
    ]

    reporter = StatTrackingReporter()
    run_tests(describe_block, reporter)

    expect(reporter.stats.test_count).to_be(1)