Rev 2835: Deprecated ``run_bzr_decode``; use the new ``output_encoding`` parameter to in http://sourcefrog.net/bzr/test-traceback
Martin Pool
mbp at sourcefrog.net
Tue Sep 18 07:31:56 BST 2007
At http://sourcefrog.net/bzr/test-traceback
------------------------------------------------------------
revno: 2835
revision-id: mbp at sourcefrog.net-20070918063155-ifdze60wpnslgdbv
parent: mbp at sourcefrog.net-20070918062825-vw07w72sphre1z9l
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: test-traceback
timestamp: Tue 2007-09-18 16:31:55 +1000
message:
Deprecated ``run_bzr_decode``; use the new ``output_encoding`` parameter to
``TestCase.run_bzr`` instead.
Removed previously deprecated varargs interface to ``TestCase.run_bzr`` and
deprecated methods ``TestCase.capture`` and ``TestCase.run_bzr_captured``.
(Martin Pool)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/symbol_versioning.py symbol_versioning.py-20060105104851-9ecf8af605d15a80
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
=== modified file 'NEWS'
--- a/NEWS 2007-09-18 05:35:31 +0000
+++ b/NEWS 2007-09-18 06:31:55 +0000
@@ -58,6 +58,14 @@
inventories without such data, pass working=True to write_inventory.
(Robert Collins)
+ * Deprecated ``run_bzr_decode``; use the new ``output_encoding`` parameter to
+ ``TestCase.run_bzr`` instead.
+ (Martin Pool)
+
+ * Removed previously deprecated varargs interface to ``TestCase.run_bzr`` and
+ deprecated methods ``TestCase.capture`` and ``TestCase.run_bzr_captured``.
+ (Martin Pool)
+
INTERNALS:
* New method on xml serialisers, write_inventory_to_lines, which matches the
=== modified file 'bzrlib/symbol_versioning.py'
--- a/bzrlib/symbol_versioning.py 2007-08-17 05:16:14 +0000
+++ b/bzrlib/symbol_versioning.py 2007-09-18 06:31:55 +0000
@@ -39,6 +39,7 @@
'zero_eighteen',
'zero_ninety',
'zero_ninetyone',
+ 'zero_ninetytwo',
]
from warnings import warn
@@ -59,6 +60,7 @@
zero_eighteen = "%s was deprecated in version 0.18."
zero_ninety = "%s was deprecated in version 0.90."
zero_ninetyone = "%s was deprecated in version 0.91."
+zero_ninetytwo = "%s was deprecated in version 0.92."
def set_warning_method(method):
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2007-09-18 05:35:31 +0000
+++ b/bzrlib/tests/__init__.py 2007-09-18 06:31:55 +0000
@@ -79,8 +79,8 @@
from bzrlib import symbol_versioning
from bzrlib.symbol_versioning import (
deprecated_method,
- zero_eighteen,
zero_ninetyone,
+ zero_ninetytwo,
)
import bzrlib.trace
from bzrlib.transport import get_transport
@@ -1284,11 +1284,6 @@
else:
return "DELETED log file to reduce memory footprint"
- @deprecated_method(zero_eighteen)
- def capture(self, cmd, retcode=0):
- """Shortcut that splits cmd into words, runs, and returns stdout"""
- return self.run_bzr_captured(cmd.split(), retcode=retcode)[0]
-
def requireFeature(self, feature):
"""This test requires a specific feature is available.
@@ -1297,25 +1292,6 @@
if not feature.available():
raise UnavailableFeature(feature)
- @deprecated_method(zero_eighteen)
- def run_bzr_captured(self, argv, retcode=0, encoding=None, stdin=None,
- working_dir=None):
- """Invoke bzr and return (stdout, stderr).
-
- Don't call this method, just use run_bzr() which is equivalent.
-
- :param argv: Arguments to invoke bzr. This may be either a
- single string, in which case it is split by shlex into words,
- or a list of arguments.
- :param retcode: Expected return code, or None for don't-care.
- :param encoding: Encoding for sys.stdout and sys.stderr
- :param stdin: A string to be used as stdin for the command.
- :param working_dir: Change to this directory before running
- """
- return self._run_bzr_autosplit(argv, retcode=retcode,
- encoding=encoding, stdin=stdin, working_dir=working_dir,
- )
-
def _run_bzr_autosplit(self, args, retcode, encoding, stdin,
working_dir):
"""Run bazaar command line, splitting up a string command line."""
@@ -1370,7 +1346,8 @@
message='Unexpected return code')
return out, err
- def run_bzr(self, *args, **kwargs):
+ def run_bzr(self, args, retcode=0, encoding=None, stdin=None,
+ working_dir=None, error_regexes=[], output_encoding=None):
"""Invoke bzr, as if it were run from the command line.
The argument list should not include the bzr program name - the
@@ -1384,9 +1361,6 @@
2- A single string, eg "add a". This is the most convenient
for hardcoded commands.
- 3- Several varargs parameters, eg run_bzr("add", "a").
- This is not recommended for new code.
-
This runs bzr through the interface that catches and reports
errors, and with logging set to something approximating the
default, so that error reporting can be checked.
@@ -1404,39 +1378,37 @@
:keyword working_dir: The directory to run the command in
:keyword error_regexes: A list of expected error messages. If
specified they must be seen in the error output of the command.
+ :keyword output_encoding: Expected encoding of output from bzr.
"""
- retcode = kwargs.pop('retcode', 0)
- encoding = kwargs.pop('encoding', None)
- stdin = kwargs.pop('stdin', None)
- working_dir = kwargs.pop('working_dir', None)
- error_regexes = kwargs.pop('error_regexes', [])
-
- if kwargs:
- raise TypeError("run_bzr() got unexpected keyword arguments '%s'"
- % kwargs.keys())
-
- if len(args) == 1:
- if isinstance(args[0], (list, basestring)):
- args = args[0]
- else:
- symbol_versioning.warn(zero_eighteen % "passing varargs to run_bzr",
- DeprecationWarning, stacklevel=3)
-
- out, err = self._run_bzr_autosplit(args=args,
+ out, err = self._run_bzr_autosplit(
+ args=args,
retcode=retcode,
- encoding=encoding, stdin=stdin, working_dir=working_dir,
+ encoding=encoding,
+ stdin=stdin,
+ working_dir=working_dir,
)
-
for regex in error_regexes:
self.assertContainsRe(err, regex)
+ if output_encoding:
+ out = out.decode(output_encoding)
+ err = err.decode(output_encoding)
return out, err
+ @deprecated_method(zero_ninetytwo)
def run_bzr_decode(self, *args, **kwargs):
+ """Run bzr and decode the output into a particular encoding.
+
+ Returns a string containing the stdout output from bzr.
+
+ This is deprecated in favour of passing output_encoding to run_bzr
+ instead.
+ """
if 'encoding' in kwargs:
encoding = kwargs['encoding']
else:
encoding = bzrlib.user_encoding
- return self.run_bzr(*args, **kwargs)[0].decode(encoding)
+ return self.run_bzr(output_encoding=encoding,
+ *args, **kwargs)[0]
def run_bzr_error(self, error_regexes, *args, **kwargs):
"""Run bzr, and check that stderr contains the supplied regexes
=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py 2007-08-15 03:51:59 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py 2007-09-18 06:31:55 +0000
@@ -111,14 +111,6 @@
self.working_dir = working_dir
return '', ''
- def test_args(self):
- """Test that run_bzr passes args correctly to _run_bzr_core"""
- self.callDeprecated(
- ['passing varargs to run_bzr was deprecated in version 0.18.'],
- self.run_bzr,
- 'arg1', 'arg2', 'arg3', retcode=1)
- self.assertEqual(['arg1', 'arg2', 'arg3'], self.argv)
-
def test_encoding(self):
"""Test that run_bzr passes encoding to _run_bzr_core"""
self.run_bzr('foo bar')
More information about the bazaar-commits
mailing list