コード例 #1
0
    def test_that_recorder_knows_package_names(self):
        destination = FakeDestination()
        with Recorder(destination, 'fake-name',
                      package_name='fake-package') as rec:
            with rec.step('a-step'):
                pass

        _, _, package_name = destination.reports['fake-name']
        self.assertEquals('fake-package', package_name)
コード例 #2
0
    def test_recorder_step(self):
        destination = FakeDestination()

        with Recorder(destination, 'fake-name') as recorder:
            with recorder.step('successful-step'):
                pass

        name, reports, _ = destination.reports['fake-name']
        self.assertEquals('fake-name', name)
        self.assertEquals(1, len(reports))
        self.assertEquals('successful-step', reports[0].name)
        assert not reports[0].failures
        assert not reports[0].errors
コード例 #3
0
    def test_recorder_no_two_step_at_a_time(self):
        def inner_step(rec):
            with rec.step('forbidden-inner-step'):
                pass

        destination = FakeDestination()
        with Recorder(destination, 'fake-name') as rec:
            with rec.step('normal-step'):
                self.assertRaises(Exception, inner_step, rec)

        name, reports, _ = destination.reports['fake-name']
        self.assertEquals('fake-name', name)
        self.assertEquals(1, len(reports))
コード例 #4
0
    def test_recorder_step_let_you_report_errors(self):
        destination = FakeDestination()

        with Recorder(destination, 'fake-name') as rec:
            with rec.step('failing-step') as step:
                step.error('my step has failed')

        name, reports, _ = destination.reports['fake-name']
        self.assertEquals(1, len(reports))
        self.assertEquals('failing-step', reports[0].name)
        self.assertEquals(1, len(reports[0].errors))
        self.assertEquals('error my step has failed', reports[0].errors[0])
        assert not reports[0].failures
コード例 #5
0
    def test_recorder_step_with_error(self):
        destination = FakeDestination()

        class SentinelException(Exception):
            pass

        try:
            with Recorder(destination, 'fake-name') as rec:
                with rec.step('failing-step'):
                    raise SentinelException()
            assert False
        except SentinelException:
            pass

        name, reports, _ = destination.reports['fake-name']
        self.assertEquals('fake-name', name)
        self.assertEquals(1, len(reports))
        self.assertEquals('failing-step', reports[0].name)
        assert not reports[0].failures
        self.assertEquals(1, len(reports[0].errors), reports)
コード例 #6
0
 def raising_fn():
     with Recorder(FakeDestination(), 'fake-name') as rec:
         raise SentinelException()
コード例 #7
0
 def test_recorder_is_a_context(self):
     self.assertRaises(Exception, Recorder(None, 'fake-name').step('step without recorder context'))