def test_something(self):
     # Temporarily suppress default log observers to avoid spewing
     # to stderr.
     self.useFixture(_NoTwistedLogObservers())
     self.useFixture(error_observer)
     log.msg('foo')
     log.err(exception)
Exemple #2
0
 def test_something(self):
     # Temporarily suppress default log observers to avoid spewing
     # to stderr.
     self.useFixture(_NoTwistedLogObservers())
     self.useFixture(error_observer)
     log.msg('foo')
     log.err(exception)
    def test_fail_job(self):
        """
        Tests that scheduler is stopped whenever a port is failing.
        """
        port_out = object()
        port_in = Mock(spec=_port_callback, side_effect=RuntimeError('failed!'))
        self.flowmap[port_out] = port_in

        run_deferred = self.scheduler.run(self.clock)
        self.scheduler.send('some item', port_out)

        expected_message = 'Job failed on {:s} while processing {:s}'.format(
            str(port_in), 'some item')

        from testtools.twistedsupport._runtest import _NoTwistedLogObservers
        with _NoTwistedLogObservers():
            with twistedsupport.CaptureTwistedLogs() as twisted_logs:
                # Trigger queue run.
                self.clock.advance(self.epsilon)
                assert_that(twisted_logs.getDetails(), matchers.MatchesDict({
                    'twisted-log': matchers.AfterPreprocessing(
                        lambda log: log.as_text(), matchers.Contains(expected_message))
                }))

        port_in.assert_called_once_with('some item', self.scheduler.send)

        matcher = matchers.AfterPreprocessing(lambda f: f.value, matchers.IsInstance(RuntimeError))
        assert_that(run_deferred, twistedsupport.failed(matcher))
 def test_something(self):
     self.useFixture(_NoTwistedLogObservers())
     log.msg('foo')
Exemple #5
0
 def test_something(self):
     self.useFixture(_NoTwistedLogObservers())
     log.msg('foo')