Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
- added missing "writelines" method to Lines adapter
Browse files Browse the repository at this point in the history
- whitespace fixes
- small test coverage increase
  • Loading branch information
benji-york committed Oct 28, 2009
1 parent 0899a30 commit 561476d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.txt
Expand Up @@ -17,13 +17,14 @@ Changes
*******

==================
1.1.4 (2009-09-??)
1.1.4 (2009-10-??)
==================

Bug fixed:

- Spurious warnings sometimes occurred due to a race condition in
setting up servers.
- Added missing "writelines" method to zc.ngi.adapters.Lines.

==================
1.1.3 (2009-07-30)
Expand Down
1 change: 1 addition & 0 deletions src/zc/ngi/adapters.py
Expand Up @@ -23,6 +23,7 @@ def __init__(self, connection):
self.connection = connection
self.close = connection.close
self.write = connection.write
self.writelines = connection.writelines

def setHandler(self, handler):
self.handler = handler
Expand Down
20 changes: 13 additions & 7 deletions src/zc/ngi/adapters.txt
Expand Up @@ -18,7 +18,7 @@ prints its input:
>>> import zc.ngi.testing
>>> connection = zc.ngi.testing.Connection()
>>> handler = zc.ngi.testing.PrintingHandler(connection)

This handler is used by default as the peer
of testing connections:

Expand Down Expand Up @@ -53,6 +53,10 @@ as would the underlying connection:
>>> adapter.write('foo')
-> 'foo'

>>> adapter.writelines(['foo', 'bar'])
-> 'foo'
-> 'bar'

>>> connection.test_close('test')
-> CLOSE test

Expand All @@ -76,7 +80,7 @@ To see this, we'll use the adapter to adapt a testing connection:

Now, we'll generate some input. We do so by providing (big-endian) sizes by
calling struct pack:

>>> import struct
>>> message1 = 'Hello\nWorld!\nHow are you?'
>>> message2 = 'This is message 2'
Expand All @@ -93,10 +97,10 @@ Here we saw that our handler got the two messages individually.
If we write a message, we can see that the message is preceded by the
message size:

>>> adapter.write(message1)
>>> adapter.write(message1)
-> '\x00\x00\x00\x19'
-> 'Hello\nWorld!\nHow are you?'

Null messages
-------------

Expand All @@ -113,8 +117,10 @@ sent to the application:

>>> connection.test_input('\xff\xff\xff\xff')

Closing
-------




Closing works too.

>>> connection.test_close('test')
-> CLOSE test

0 comments on commit 561476d

Please sign in to comment.