Rev 5296: (mbp) ignore common leading whitespace in shell-like script tests (Martin in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Jun 15 10:03:39 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5296 [merge]
revision-id: pqm at pqm.ubuntu.com-20100615090338-g5bvhjufbbpllado
parent: pqm at pqm.ubuntu.com-20100615070643-igufk0cmdpkg4ypc
parent: mbp at canonical.com-20100615074429-jovojdihputikv6z
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-06-15 10:03:38 +0100
message:
(mbp) ignore common leading whitespace in shell-like script tests (Martin
Pool)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/script.py script.py-20090901081155-yk3tiy1nunxg16ne-1
bzrlib/tests/test_script.py test_script.py-20090901081156-y90z4w2t62fv7e7b-1
doc/developers/testing.txt testing.txt-20080812140359-i70zzh6v2z7grqex-1
=== modified file 'NEWS'
--- a/NEWS 2010-06-15 04:32:49 +0000
+++ b/NEWS 2010-06-15 07:44:29 +0000
@@ -36,6 +36,10 @@
* ``bzr log --exclude-common-ancestry`` is now taken into account for
linear ancetries. (Vincent Ladeuil, #575631)
+* ``bzr pull`` now works when a lp: URL is explicitly defined as the parent
+ or pull location in locations.conf or branch.conf.
+ (Gordon Tyler, #534787)
+
* Ensure that wrong path specifications in ``BZR_PLUGINS_AT`` display
proper error messages. (Vincent Ladeuil, #591215)
@@ -52,13 +56,13 @@
test that all commands available to the test suite have help.
(Robert Collins, #177500)
+* ``ScriptRunner`` now strips off leading indentation from test scripts,
+ which previously caused "SyntaxError: No command for line".
+ (Martin Pool)
+
* Relative imports in plugins are now handled correctly when using
BZR_PLUGINS_AT. (Vincent Ladeuil, #588959)
-* ``bzr pull`` now works when a lp: URL is explicitly defined as the parent
- or pull location in locations.conf or branch.conf.
- (Gordon Tyler, #534787)
-
Improvements
************
=== modified file 'bzrlib/tests/script.py'
--- a/bzrlib/tests/script.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/script.py 2010-06-11 06:33:15 +0000
@@ -24,6 +24,7 @@
import glob
import os
import shlex
+import textwrap
from cStringIO import StringIO
from bzrlib import (
@@ -73,6 +74,7 @@
cmd_line = 1
lineno = 0
input, output, error = None, None, None
+ text = textwrap.dedent(text)
for line in text.split('\n'):
lineno += 1
# Keep a copy for error reporting
@@ -475,3 +477,7 @@
def run_command(self, cmd, input, output, error):
return self.script_runner.run_command(self, cmd, input, output, error)
+
+def run_script(test_case, script_string):
+ """Run the given script within a testcase"""
+ return ScriptRunner().run_script(test_case, script_string)
=== modified file 'bzrlib/tests/test_script.py'
--- a/bzrlib/tests/test_script.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/test_script.py 2010-06-11 06:33:15 +0000
@@ -51,6 +51,18 @@
[(['cat', '>file'], 'content\n', None, None)],
script._script_to_commands('$ cat >file\n<content\n'))
+ def test_indented(self):
+ # scripts are commonly given indented within the test source code, and
+ # common indentation is stripped off
+ story = """
+ $ bzr add
+ adding file
+ adding file2
+ """
+ self.assertEquals([(['bzr', 'add'], None,
+ 'adding file\nadding file2\n', None)],
+ script._script_to_commands(story))
+
def test_command_with_output(self):
story = """
$ bzr add
=== modified file 'doc/developers/testing.txt'
--- a/doc/developers/testing.txt 2010-06-04 03:09:35 +0000
+++ b/doc/developers/testing.txt 2010-06-11 06:19:48 +0000
@@ -395,20 +395,21 @@
The actual use of ScriptRunner within a TestCase looks something like
this::
- def test_unshelve_keep(self):
- # some setup here
- sr = ScriptRunner()
- sr.run_script(self, '''
- $ bzr add file
- $ bzr shelve --all -m Foo
- $ bzr shelve --list
- 1: Foo
- $ bzr unshelve --keep
- $ bzr shelve --list
- 1: Foo
- $ cat file
- contents of file
- ''')
+ from bzrlib.tests import script
+
+ def test_unshelve_keep(self):
+ # some setup here
+ script.run_script(self, '''
+ $ bzr add file
+ $ bzr shelve --all -m Foo
+ $ bzr shelve --list
+ 1: Foo
+ $ bzr unshelve --keep
+ $ bzr shelve --list
+ 1: Foo
+ $ cat file
+ contents of file
+ ''')
Import tariff tests
@@ -872,4 +873,4 @@
.. |--| unicode:: U+2014
..
- vim: ft=rst tw=74 ai
+ vim: ft=rst tw=74 ai et sw=4
More information about the bazaar-commits
mailing list