Rev 4889: Test how _read_bytes works. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-client-reconnect-819604
John Arbash Meinel
john at arbash-meinel.com
Wed Sep 28 15:07:57 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-client-reconnect-819604
------------------------------------------------------------
revno: 4889
revision-id: john at arbash-meinel.com-20110928150744-s2y7j1o62iw4py3d
parent: john at arbash-meinel.com-20110928145848-lrno0pmindirh1zz
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-client-reconnect-819604
timestamp: Wed 2011-09-28 17:07:44 +0200
message:
Test how _read_bytes works.
It appears that when the process dies, you just get EOF (empty string) from read,
which is nice, given that writing gives problems.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py 2011-09-28 14:55:36 +0000
+++ b/bzrlib/tests/test_smart_transport.py 2011-09-28 15:07:44 +0000
@@ -229,7 +229,26 @@
def test_simple_pipes__flush_subprocess_closed(self):
p = subprocess.Popen([sys.executable, '-c',
+ 'import sys, os, msvcrt\n'
+ 'msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)\n'
+ 'msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)\n'
+ 'sys.stdout.write(sys.stdin.read(4))\n'
+ 'sys.stdout.close()\n'],
+ stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ client_medium = medium.SmartSimplePipesClientMedium(
+ p.stdout, p.stdin, 'base')
+ client_medium._accept_bytes('abc\n')
+ p.wait()
+ # Even though the child process is dead, flush seems to be a no-op.
+ client_medium._flush()
+
+ def test_simple_pipes__read_bytes_subprocess_closed(self):
+ p = subprocess.Popen([sys.executable, '-c',
'import sys\n'
+ 'if sys.platform == "win32":\n'
+ ' import msvcrt, os\n'
+ ' msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)\n'
+ ' msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)\n'
'sys.stdout.write(sys.stdin.read(4))\n'
'sys.stdout.close()\n'],
stdout=subprocess.PIPE, stdin=subprocess.PIPE)
@@ -237,8 +256,8 @@
p.stdout, p.stdin, 'base')
client_medium._accept_bytes('abc\n')
p.wait()
- # Even though the child process is dead, flush seems to be a no-op.
- client_medium._flush()
+ self.assertEqual('abc\n', client_medium._read_bytes(4))
+ self.assertEqual('', client_medium._read_bytes(4))
def test_simple_pipes_client_disconnect_does_nothing(self):
# calling disconnect does nothing.
More information about the bazaar-commits
mailing list