[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-88]
add Message.rewind() add rewind() method to Message, which just resets the pointer so you can start reading from the beginning again. this is useful for some tests.
This commit is contained in:
parent
12287b3e0e
commit
3e644a94f1
|
@ -61,6 +61,13 @@ class Message (object):
|
|||
"""
|
||||
return 'paramiko.Message(' + repr(self.packet) + ')'
|
||||
|
||||
def rewind(self):
|
||||
"""
|
||||
Rewind the message to the beginning as if no items had been parsed
|
||||
out of it yet.
|
||||
"""
|
||||
self.idx = 0
|
||||
|
||||
def get_remainder(self):
|
||||
"""
|
||||
Return the bytes of this Message that haven't already been parsed and
|
||||
|
|
|
@ -95,4 +95,8 @@ class MessageTest (unittest.TestCase):
|
|||
self.assertEquals(msg.get_mpint(), 0x1122334455L)
|
||||
self.assertEquals(msg.get_so_far(), self.__d[:13])
|
||||
self.assertEquals(msg.get_remainder(), self.__d[13:])
|
||||
msg.rewind()
|
||||
self.assertEquals(msg.get_int(), 5)
|
||||
self.assertEquals(msg.get_so_far(), self.__d[:4])
|
||||
self.assertEquals(msg.get_remainder(), self.__d[4:])
|
||||
|
||||
|
|
Loading…
Reference in New Issue