def test__when_a_before_block_fails__it_runs_it_blocks_in_the_next_describe(): reset() context = test_collection.current_describe.context context.calls = [] @describe def outer_describe(): @describe def some_describe(): @before_each def some_before_each_that_raises(self): raise Exception("Some Setup exception") @it def some_test(): pass @describe def some_second_describe(): @it def some_second_test(self): self.calls.append("some-it") outer_describe = test_collection.current_describe.describe_blocks[0] test_collection.collect_describe(outer_describe) try: run_tests(test_collection.top_level_describe, ExceptionReporter()) except Exception: pass finally: expect(context.calls).to_be(["some-it"])
def test__when_there_are_before_each_blocks_for_another_describe__it_doesnt_run_them( ): reset() context = test_collection.current_describe.context context.calls = [] @describe def when_context_1(): @describe def when_context_2(): @before_each def do(self): self.calls.append("before1") @describe def when_context_3(): @it def do_something_1(self): self.calls.append("it1") outer_describe = test_collection.current_describe.describe_blocks[0] test_collection.collect_describe(outer_describe) run_tests(test_collection.top_level_describe, ExceptionReporter()) expect(context.calls).to_be(["it1"])
def test__when_there_are_nested_describes__it_runs_them(): reset() context = test_collection.current_describe.context context.calls = [] @describe def when_context_1(): @it def do_first_thing(self): self.calls.append("it1") @describe def when_context_2(): @describe def when_context_3(): @it def do_second_thing(self): self.calls.append("it2") @describe def when_context_4(): @it def do_third_thing(self): self.calls.append("it3") @it def do_fourth_thing(self): self.calls.append("it4") outer_describe = test_collection.current_describe.describe_blocks[0] test_collection.collect_describe(outer_describe) run_tests(test_collection.top_level_describe, ExceptionReporter()) expect(context.calls).to_be(["it1", "it2", "it3", "it4"])
def pyne(tests_method): if config.report_between_suites: reporter.reset() describe_block = DescribeBlock(None, tests_method.__name__, tests_method) test_collection.collect_describe(describe_block) if config.report_between_suites: run_tests(describe_block, reporter) return tests_method
def test__when_there_are_before_each_blocks_in_parent_describes__runs_them_before_each_test( ): reset() context = test_collection.current_describe.context context.calls = [] @describe def when_context_1(): @before_each def do(self): self.calls.append("before1") @describe def when_context_2(): @before_each def do(self): self.calls.append("before2") @describe def when_context_3(): @before_each def do(self): self.calls.append("before3") @it def do_first_thing(self): self.calls.append("it1") @it def do_second_thing(self): self.calls.append("it2") outer_describe = test_collection.current_describe.describe_blocks[0] test_collection.collect_describe(outer_describe) blocks_ = outer_describe.describe_blocks[0] nested_describe = blocks_.describe_blocks[0] run_tests(nested_describe, ExceptionReporter()) expect(context.calls).to_be([ "before1", "before2", "before3", "it1", "before1", "before2", "before3", "it2" ])
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)
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)