Rev 3654: Fix the test suite. in http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/hpss_readv

John Arbash Meinel john at arbash-meinel.com
Fri Aug 29 02:55:33 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/hpss_readv

------------------------------------------------------------
revno: 3654
revision-id: john at arbash-meinel.com-20080829015532-d26jj843xwt7ad8u
parent: john at arbash-meinel.com-20080828213619-0wq19y99l96lja2t
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: hpss_readv
timestamp: Thu 2008-08-28 20:55:32 -0500
message:
  Fix the test suite.
  Remove the 'assert' statements and turn them into raise AssertionError
  Fix the test that assumed ProtoThreeDecoder had an '_in_buffer'
  member.
-------------- next part --------------
=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py	2008-08-28 21:04:35 +0000
+++ b/bzrlib/smart/protocol.py	2008-08-29 01:55:32 +0000
@@ -323,7 +323,6 @@
 
     def __init__(self):
         self.finished_reading = False
-        # self._in_buffer = None
         self._in_buffer_list = []
         self._in_buffer_len = 0
         self.unused_data = ''
@@ -334,7 +333,10 @@
         if len(self._in_buffer_list) == 1:
             return self._in_buffer_list[0]
         in_buffer = ''.join(self._in_buffer_list)
-        assert len(in_buffer) == self._in_buffer_len
+        if len(in_buffer) != self._in_buffer_len:
+            raise AssertionError(
+                "Length of buffer did not match expected value: %s != %s"
+                % self._in_buffer_len, len(in_buffer))
         self._in_buffer_list = [in_buffer]
         return in_buffer
 
@@ -347,7 +349,9 @@
         _set_in_buffer() if they actually need to consume the bytes.
         """
         # check if we can yield the bytes from just the first entry in our list
-        assert len(self._in_buffer_list) > 0
+        if len(self._in_buffer_list) == 0:
+            raise AssertionError('Callers must be sure we have buffered bytes'
+                ' before calling _get_in_bytes')
         if len(self._in_buffer_list[0]) > count:
             return self._in_buffer_list[0][:count]
         # We can't yield it from the first buffer, so collapse all buffers, and

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2008-06-17 04:32:18 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2008-08-29 01:55:32 +0000
@@ -2267,7 +2267,8 @@
     def test_construct_version_three_server_protocol(self):
         smart_protocol = protocol.ProtocolThreeDecoder(None)
         self.assertEqual('', smart_protocol.unused_data)
-        self.assertEqual('', smart_protocol._in_buffer)
+        self.assertEqual([], smart_protocol._in_buffer_list)
+        self.assertEqual(0, smart_protocol._in_buffer_len)
         self.assertFalse(smart_protocol._has_dispatched)
         # The protocol starts by expecting four bytes, a length prefix for the
         # headers.



More information about the bazaar-commits mailing list