def test_skipped_spec_is_not_run(self): self.run_spec( [examples.this_spec_should_be_skipped], 'this spec should be skipped' ) self.mock.assert_has_calls([ call.skip(self.spec, '(skipped spec)', 'skipped spec'), call.spec_complete() ])
def test_spec_with_error_before_assertions_with_no_cleanup(self): self.run_spec( [examples.spec_with_error_before_assertions_without_cleanup], 'spec with error before assertions without cleanup' ) self.assertSequenceEqual(self.mock.mock_calls, [ call.error(self.spec, 'when', 'an exception is raised', ANY), call.spec_complete(), ]) self.assertIsInstance(self._extract_exception_from_call(0), KeyError)
def test_skipped_step_is_not_run(self): self.run_spec( [examples.skipped_assertion], 'skipped assertion' ) self.mock.assert_has_calls([ call.success(self.spec, 'given', 'some scenario'), call.success(self.spec, 'when', 'something is invoked'), call.success(self.spec, 'collect', 'results'), call.skip(self.spec, 'then', 'something happens'), call.success(self.spec, 'then', 'something is calculated'), call.success(self.spec, 'after', 'cleanup'), call.spec_complete() ])
def test_excessive_use_of_spec_step_methods(self): self.run_spec( [examples.spec_with_multiple_givens, examples.spec_with_multiple_whens, examples.spec_with_multiple_collects, examples.spec_with_multiple_afters], ['spec with multiple givens', 'spec with multiple whens', 'spec with multiple collects', 'spec with multiple afters',] ) self.mock.assert_has_calls([ call.error(self.spec[0], 'collect steps', 'extra steps', ANY), call.spec_complete(), call.error(self.spec[1], 'collect steps', 'extra steps', ANY), call.spec_complete(), call.error(self.spec[2], 'collect steps', 'extra steps', ANY), call.spec_complete(), call.error(self.spec[3], 'collect steps', 'extra steps', ANY), call.spec_complete(), ]) exceptions = [self._extract_exception_from_call(x) for x in [0, 2, 4, 6]] self.assertTrue( all(isinstance(e, SpecInitializationError) for e in exceptions)) expected_messages = [ "The spec (spec with multiple givens) " "has extra steps (['given']).", "The spec (spec with multiple whens) " "has extra steps (['when']).", "The spec (spec with multiple collects) " "has extra steps (['collect']).", "The spec (spec with multiple afters) " "has extra steps (['after']).", ] self.assertSequenceEqual( expected_messages, [e.message for e in exceptions])