~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-08-02 07:22:05 UTC
  • mfrom: (2621.3.3 smart-server-logging)
  • Revision ID: pqm@pqm.ubuntu.com-20070802072205-gjk1eev6rlw7ght8
(Andrew Bennetts) Log errors from the smart server in the trace file, to make debugging test failures (and live failures!) easier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1343
1343
        self.assertEqual(expected_tuple, smart_protocol.read_response_tuple())
1344
1344
 
1345
1345
 
1346
 
class TestSmartProtocolOne(TestSmartProtocol):
 
1346
class CommonSmartProtocolTestMixin(object):
 
1347
 
 
1348
    def test_errors_are_logged(self):
 
1349
        """If an error occurs during testing, it is logged to the test log."""
 
1350
        out_stream = StringIO()
 
1351
        smart_protocol = self.server_protocol_class(None, out_stream.write)
 
1352
        # This triggers a "bad request" error.
 
1353
        smart_protocol.accept_bytes('abc\n')
 
1354
        test_log = self._get_log(keep_log_file=True)
 
1355
        self.assertContainsRe(test_log, 'Traceback')
 
1356
        self.assertContainsRe(test_log, 'SmartProtocolError')
 
1357
 
 
1358
 
 
1359
class TestSmartProtocolOne(TestSmartProtocol, CommonSmartProtocolTestMixin):
1347
1360
    """Tests for the smart protocol version one."""
1348
1361
 
1349
1362
    client_protocol_class = protocol.SmartClientRequestProtocolOne
1564
1577
            errors.ReadingCompleted, smart_protocol.read_body_bytes)
1565
1578
 
1566
1579
 
1567
 
class TestSmartProtocolTwo(TestSmartProtocol):
 
1580
class TestSmartProtocolTwo(TestSmartProtocol, CommonSmartProtocolTestMixin):
1568
1581
    """Tests for the smart protocol version two.
1569
1582
 
1570
1583
    This test case is mostly the same as TestSmartProtocolOne.