예제 #1
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 def test_spec_with_assertion_error(self):
     self.run_spec(
         [examples.spec_with_assertion_error], 'spec with assertion error'
     )
     self.mock.assert_has_calls([
         call.error(self.spec, 'then', 'it should raise an error', ANY),
         call.success(self.spec, 'then', 'it should run other assertions'),
         call.success(self.spec, 'after', 'cleanup')
     ])
     self.assertIsInstance(self._extract_exception_from_call(0), KeyError)
예제 #2
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 def test_spec_with_errors_before_and_after_assertions(self):
     self.run_spec(
         [examples.spec_with_error_before_and_after_assertions],
         'spec with error before and after assertions'
     )
     self.mock.assert_has_calls([
         call.success(self.spec, 'given', 'setup'),
         call.success(self.spec, 'when', 'action'),
         call.error(self.spec, 'collect', 'result', ANY),
         call.error(self.spec, 'after', 'an exception is raised', ANY)
     ])
     self.assertIsInstance(self._extract_exception_from_call(2), KeyError)
     self.assertIsInstance(self._extract_exception_from_call(3), ValueError)
예제 #3
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 def test_spec_with_error_before_assertions(self):
     self.run_spec(
         [examples.spec_with_error_before_assertions],
         'spec with error before assertions'
     )
     self.mock.assert_has_calls([
         call.error(self.spec, 'given', 'an exception is raised', ANY),
         call.success(self.spec, 'after', 'should be executed to clean up')
     ])
     self.assertNotIn(call.success(ANY, 'when', ANY), self.calls)
     self.assertNotIn(call.success(ANY, 'collect', ANY), self.calls)
     self.assertNotIn(call.success(ANY, 'then', ANY), self.calls)
     self.assertIsInstance(self._extract_exception_from_call(0), KeyError)
예제 #4
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 def test_spec_with_error_after_assertions(self):
     self.run_spec(
         [examples.spec_with_error_after_assertions],
         'spec with error after assertions'
     )
     self.mock.assert_has_calls([
         call.success(self.spec, 'given', 'setup'),
         call.success(self.spec, 'when', 'action'),
         call.success(self.spec, 'collect', 'result'),
         call.success(self.spec, 'then', 'something'),
         call.success(self.spec, 'then', 'something else'),
         call.error(self.spec, 'after', 'an exception is raised', ANY)
     ])
     self.assertIsInstance(self._extract_exception_from_call(-2), KeyError)
예제 #5
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 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()
     ])
예제 #6
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
    def test_spec_with_assertion_failure(self):
        self.run_spec([examples.spec_with_failure], 'spec with failure')

        self.mock.assert_has_calls([
            call.failure(self.spec, 'it should fail', ANY),
            call.success(self.spec, 'then', 'it should run other assertions')],
            any_order=True
        )
        self.assertIsInstance(
            self._extract_exception_from_call(0), AssertionError)
예제 #7
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 def test_full_passing(self):
     self.run_spec(
         [examples.fully_implemented_and_passing],
         'fully implemented and passing'
     )
     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.success(self.spec, 'then', 'something happens'),
         call.success(self.spec, 'then', 'something is calculated'),
         call.success(self.spec, 'after', 'cleanup')]
     )
예제 #8
0
파일: test_spec.py 프로젝트: hfeeki/pyspecs
 def test_inheritance_of_steps(self):
     self.run_spec(
         [examples.child],
         'child, using a parent'
     )
     self.mock.assert_has_calls([
         call.success(self.spec, 'given', 'setup'),
         call.success(self.spec, 'when', 'action'),
         call.success(self.spec, 'collect', 'results'),
         call.success(self.spec, 'then', 'something'),
         call.success(self.spec, 'then', 'something else'),
         call.success(self.spec, 'after', 'cleanup')
     ])