def spec(w): def failed_test_function(self): assert False example = Example("reports failure", failed_test_function) result = example.run(MockExampleGroup(), return_world(w.mock_world)) assert type(result) == ExampleResult assert type(result.exception) is AssertionError assert result.traceback is not None assert result.kind == 2
def spec(w): an_error = Exception("An Error") def bad_test_function(self): raise an_error example = Example("reports error", bad_test_function) result = example.run(MockExampleGroup(), return_world(w.mock_world)) assert type(result) == ExampleResult assert result.exception is an_error assert result.traceback is not None assert result.kind == 3
def spec(w): example = Example("runs before method from context", passing_spec_function) example.run(MockExampleGroup(), return_world(w.mock_world)) assert w.mock_world.before_was_run
def spec(w): example = Example("reports success", passing_spec_function) result = example.run(MockExampleGroup(), return_world(w.mock_world)) assert type(result) == ExampleResult assert result.kind == 1 assert result.traceback is None
def spec(w): example = Example("can be run", passing_spec_function) example.run(MockExampleGroup(), return_world(w.mock_world)) assert w.mock_world.has_been_run