Rev 5604: (jameinel) Use Transport.get_bytes() instead of Transport.get().read() in in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jan 12 23:02:31 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5604 [merge]
revision-id: pqm at pqm.ubuntu.com-20110112230230-p0dzwke9han3t0ud
parent: pqm at pqm.ubuntu.com-20110112222059-opcgh8rveshvbb70
parent: john at arbash-meinel.com-20110112221224-v5nws3bt9o787mjd
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-01-12 23:02:30 +0000
message:
(jameinel) Use Transport.get_bytes() instead of Transport.get().read() in
the test suite. (John A Meinel)
modified:
bzrlib/tests/per_transport.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/tests/per_transport.py'
--- a/bzrlib/tests/per_transport.py 2011-01-10 22:20:12 +0000
+++ b/bzrlib/tests/per_transport.py 2011-01-12 21:50:12 +0000
@@ -101,8 +101,8 @@
self.overrideEnv('BZR_NO_SMART_VFS', None)
def check_transport_contents(self, content, transport, relpath):
- """Check that transport.get(relpath).read() == content."""
- self.assertEqualDiff(content, transport.get(relpath).read())
+ """Check that transport.get_bytes(relpath) == content."""
+ self.assertEqualDiff(content, transport.get_bytes(relpath))
def test_ensure_base_missing(self):
""".ensure_base() should create the directory if it doesn't exist"""
@@ -256,7 +256,7 @@
handle = t.open_write_stream('foo')
try:
handle.write('b')
- self.assertEqual('b', t.get('foo').read())
+ self.assertEqual('b', t.get_bytes('foo'))
finally:
handle.close()
@@ -268,7 +268,11 @@
try:
handle.write('b')
self.assertEqual('b', t.get_bytes('foo'))
- self.assertEqual('b', t.get('foo').read())
+ f = t.get('foo')
+ try:
+ self.assertEqual('b', f.read())
+ finally:
+ f.close()
finally:
handle.close()
@@ -640,7 +644,7 @@
self.build_tree(files, transport=transport_from)
self.assertEqual(4, transport_from.copy_to(files, transport_to))
for f in files:
- self.check_transport_contents(transport_to.get(f).read(),
+ self.check_transport_contents(transport_to.get_bytes(f),
transport_from, f)
t = self.get_transport()
@@ -669,7 +673,7 @@
files = ['a', 'b', 'c', 'd']
t.copy_to(iter(files), temp_transport)
for f in files:
- self.check_transport_contents(temp_transport.get(f).read(),
+ self.check_transport_contents(temp_transport.get_bytes(f),
t, f)
del temp_transport
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2011-01-12 22:20:59 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2011-01-12 23:02:30 +0000
@@ -73,6 +73,13 @@
trying to set the tags in the master branch. This had been broken by the
bug fix for bug #603395. (John Arbash Meinel, #701212)
+* Per-transport tests now prefer to use ``Transport.get_bytes()`` rather
+ than ``Transport.get().read()``. The SFTP code uses an async message to
+ close the file handle if you let the handle die from refcounting, while
+ it uses a synchronous message if you close it directly. This should help
+ prevent random test suite failures from race conditions.
+ (John Arbash Meinel, #681047)
+
* Stop using ``bzrlib.tuned_gzip.GzipFile``. It is incompatible with
python-2.7 and was only used for Knit format repositories, which haven't
been recommended since 2007. The file itself will be removed in the next
More information about the bazaar-commits
mailing list