[Checkins] SVN: zc.ngi/branches/jim-dev/src/zc/ngi/adapters. Added missing writelines tests and fixed a bug in writelines in the
Jim Fulton
jim at zope.com
Fri Jun 11 17:18:17 EDT 2010
Log message for revision 113371:
Added missing writelines tests and fixed a bug in writelines in the
base adapter.
Changed:
U zc.ngi/branches/jim-dev/src/zc/ngi/adapters.py
U zc.ngi/branches/jim-dev/src/zc/ngi/adapters.txt
-=-
Modified: zc.ngi/branches/jim-dev/src/zc/ngi/adapters.py
===================================================================
--- zc.ngi/branches/jim-dev/src/zc/ngi/adapters.py 2010-06-11 21:08:24 UTC (rev 113370)
+++ zc.ngi/branches/jim-dev/src/zc/ngi/adapters.py 2010-06-11 21:18:17 UTC (rev 113371)
@@ -29,9 +29,9 @@
self.write = self.connection.write
self.write(data)
- def writelined(self, data):
- self.writelined = self.connection.writelined
- self.writelined(data)
+ def writelines(self, data):
+ self.writelines = self.connection.writelines
+ self.writelines(data)
def setHandler(self, handler):
self.handler = handler
Modified: zc.ngi/branches/jim-dev/src/zc/ngi/adapters.txt
===================================================================
--- zc.ngi/branches/jim-dev/src/zc/ngi/adapters.txt 2010-06-11 21:08:24 UTC (rev 113370)
+++ zc.ngi/branches/jim-dev/src/zc/ngi/adapters.txt 2010-06-11 21:18:17 UTC (rev 113371)
@@ -18,7 +18,7 @@
>>> 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:
@@ -53,6 +53,19 @@
>>> adapter.write('foo')
-> 'foo'
+ >>> adapter.writelines("%s\n" % foo for foo in range(3))
+ -> '0\n'
+ -> '1\n'
+ -> '2\n'
+
+.. again with feeling
+
+ >>> adapter.writelines("%s\n" % foo for foo in range(3))
+ -> '0\n'
+ -> '1\n'
+ -> '2\n'
+
+::
>>> connection.test_close('test')
-> CLOSE test
@@ -76,7 +89,7 @@
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'
@@ -93,10 +106,21 @@
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?'
-
+
+We can gibe multiple messages using writelines:
+
+ >>> adapter.writelines("%s\n" % foo for foo in range(3))
+ -> '\x00\x00\x00\x02'
+ -> '0\n'
+ -> '\x00\x00\x00\x02'
+ -> '1\n'
+ -> '\x00\x00\x00\x02'
+ -> '2\n'
+
+
Null messages
-------------
@@ -114,7 +138,7 @@
>>> connection.test_input('\xff\xff\xff\xff')
-
+
More information about the checkins
mailing list