Rev 5274: Cleanup some imports in bzrlib.tests. in file:///home/vila/src/bzr/experimental/leaking-tests/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon May 31 22:24:27 BST 2010
At file:///home/vila/src/bzr/experimental/leaking-tests/
------------------------------------------------------------
revno: 5274
revision-id: v.ladeuil+lp at free.fr-20100531212427-uy0yy1aninf60zrk
parent: pqm at pqm.ubuntu.com-20100531202104-cbjsq49mc53mpiqo
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: cleanup
timestamp: Mon 2010-05-31 23:24:27 +0200
message:
Cleanup some imports in bzrlib.tests.
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2010-05-25 17:27:52 +0000
+++ b/bzrlib/tests/__init__.py 2010-05-31 21:24:27 +0000
@@ -29,7 +29,7 @@
import atexit
import codecs
-from copy import copy
+import copy
from cStringIO import StringIO
import difflib
import doctest
@@ -37,12 +37,12 @@
import logging
import math
import os
-from pprint import pformat
+import pprint
import random
import re
import shlex
import stat
-from subprocess import Popen, PIPE, STDOUT
+import subprocess
import sys
import tempfile
import threading
@@ -74,6 +74,7 @@
ui,
urlutils,
registry,
+ transport as _mod_transport,
workingtree,
)
import bzrlib.branch
@@ -103,11 +104,9 @@
)
import bzrlib.trace
from bzrlib.transport import (
- get_transport,
memory,
pathfilter,
)
-import bzrlib.transport
from bzrlib.trace import mutter, note
from bzrlib.tests import (
test_server,
@@ -943,7 +942,7 @@
def permit_dir(self, name):
"""Permit a directory to be used by this test. See permit_url."""
- name_transport = get_transport(name)
+ name_transport = _mod_transport.get_transport(name)
self.permit_url(name)
self.permit_url(name_transport.base)
@@ -1028,7 +1027,7 @@
self.addCleanup(transport_server.stop_server)
# Obtain a real transport because if the server supplies a password, it
# will be hidden from the base on the client side.
- t = get_transport(transport_server.get_url())
+ t = _mod_transport.get_transport(transport_server.get_url())
# Some transport servers effectively chroot the backing transport;
# others like SFTPServer don't - users of the transport can walk up the
# transport to read the entire backing transport. This wouldn't matter
@@ -1095,7 +1094,7 @@
message += '\n'
raise AssertionError("%snot equal:\na = %s\nb = %s\n"
% (message,
- pformat(a), pformat(b)))
+ pprint.pformat(a), pprint.pformat(b)))
assertEquals = assertEqual
@@ -1986,7 +1985,9 @@
if not allow_plugins:
command.append('--no-plugins')
command.extend(process_args)
- process = self._popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ process = self._popen(command, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
finally:
restore_environment()
if cwd is not None:
@@ -2000,7 +2001,7 @@
Allows tests to override this method to intercept the calls made to
Popen for introspection.
"""
- return Popen(*args, **kwargs)
+ return subprocess.Popen(*args, **kwargs)
def get_source_path(self):
"""Return the path of the directory containing bzrlib."""
@@ -2186,7 +2187,7 @@
:param relpath: a path relative to the base url.
"""
- t = get_transport(self.get_url(relpath))
+ t = _mod_transport.get_transport(self.get_url(relpath))
self.assertFalse(t.is_readonly())
return t
@@ -2198,7 +2199,7 @@
:param relpath: a path relative to the base url.
"""
- t = get_transport(self.get_readonly_url(relpath))
+ t = _mod_transport.get_transport(self.get_readonly_url(relpath))
self.assertTrue(t.is_readonly())
return t
@@ -2334,7 +2335,7 @@
propagating. This method ensures than a test did not leaked.
"""
root = TestCaseWithMemoryTransport.TEST_ROOT
- self.permit_url(get_transport(root).base)
+ self.permit_url(_mod_transport.get_transport(root).base)
wt = workingtree.WorkingTree.open(root)
last_rev = wt.last_revision()
if last_rev != 'null:':
@@ -2385,7 +2386,7 @@
# might be a relative or absolute path
maybe_a_url = self.get_url(relpath)
segments = maybe_a_url.rsplit('/', 1)
- t = get_transport(maybe_a_url)
+ t = _mod_transport.get_transport(maybe_a_url)
if len(segments) > 1 and segments[-1] not in ('', '.'):
t.ensure_base()
if format is None:
@@ -2411,7 +2412,8 @@
def make_smart_server(self, path):
smart_server = test_server.SmartTCPServer_for_testing()
self.start_server(smart_server, self.get_server())
- remote_transport = get_transport(smart_server.get_url()).clone(path)
+ remote_transport = _mod_transport.get_transport(smart_server.get_url()
+ ).clone(path)
return remote_transport
def make_branch_and_memory_tree(self, relpath, format=None):
@@ -2566,7 +2568,7 @@
"a list or a tuple. Got %r instead" % (shape,))
# It's OK to just create them using forward slashes on windows.
if transport is None or transport.is_readonly():
- transport = get_transport(".")
+ transport = _mod_transport.get_transport(".")
for name in shape:
self.assertIsInstance(name, basestring)
if name[-1] == '/':
@@ -3313,10 +3315,12 @@
'--subunit']
if '--no-plugins' in sys.argv:
argv.append('--no-plugins')
- # stderr=STDOUT would be ideal, but until we prevent noise on
- # stderr it can interrupt the subunit protocol.
- process = Popen(argv, stdin=PIPE, stdout=PIPE, stderr=PIPE,
- bufsize=1)
+ # stderr=subrocess.STDOUT would be ideal, but until we prevent
+ # noise on stderr it can interrupt the subunit protocol.
+ process = subrocess.Popen(argv, stdin=subrocess.PIPE,
+ stdout=subrocess.PIPE,
+ stderr=subrocess.PIPE,
+ bufsize=1)
test = TestInSubprocess(process, test_list_file_name)
result.append(test)
except:
@@ -4038,7 +4042,7 @@
:param new_id: The id to assign to it.
:return: The new test.
"""
- new_test = copy(test)
+ new_test = copy.copy(test)
new_test.id = lambda: new_id
return new_test
More information about the bazaar-commits
mailing list