Rev 5513: (gz) Fix test-script making bzr help depend on testtools (Martin von Gagern) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Oct 22 18:34:37 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5513 [merge]
revision-id: pqm at pqm.ubuntu.com-20101022173435-z6cspzmcc689ybdz
parent: pqm at pqm.ubuntu.com-20101022042417-dz3o0rtnwcgfowwx
parent: martin.vgagern at gmx.net-20101020192046-yjunbp9d5zttceia
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-10-22 18:34:35 +0100
message:
(gz) Fix test-script making bzr help depend on testtools (Martin von Gagern)
added:
bzrlib/cmd_test_script.py cmd_test_script.py-20101020120519-7hst41avona524nn-1
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/script.py script.py-20090901081155-yk3tiy1nunxg16ne-1
bzrlib/tests/test_import_tariff.py test_import_tariff.p-20100207155145-ff9infp7goncs7zh-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2010-10-18 12:36:03 +0000
+++ b/bzrlib/builtins.py 2010-10-20 12:06:13 +0000
@@ -6109,6 +6109,6 @@
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
('cmd_conflicts', [], 'bzrlib.conflicts'),
('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
- ('cmd_test_script', [], 'bzrlib.tests.script'),
+ ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
]:
builtin_command_registry.register_lazy(name, aliases, module_name)
=== added file 'bzrlib/cmd_test_script.py'
--- a/bzrlib/cmd_test_script.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/cmd_test_script.py 2010-10-20 19:20:46 +0000
@@ -0,0 +1,57 @@
+# Copyright (C) 2009, 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Front-end command for shell-like test scripts.
+
+See developers/testing.html for more explanations.
+This module should be importable even if testtools aren't available.
+"""
+
+import os
+
+from bzrlib import commands
+
+
+class cmd_test_script(commands.Command):
+ """Run a shell-like test from a file."""
+
+ hidden = True
+ takes_args = ['infile']
+
+ @commands.display_command
+ def run(self, infile):
+ # local imports to defer testtools dependency
+ from bzrlib import tests
+ from bzrlib.tests.script import TestCaseWithTransportAndScript
+
+ f = open(infile)
+ try:
+ script = f.read()
+ finally:
+ f.close()
+
+ class Test(TestCaseWithTransportAndScript):
+
+ script = None # Set before running
+
+ def test_it(self):
+ self.run_script(script)
+
+ runner = tests.TextTestRunner(stream=self.outf)
+ test = Test('test_it')
+ test.path = os.path.realpath(infile)
+ res = runner.run(test)
+ return len(res.errors) + len(res.failures)
=== modified file 'bzrlib/tests/script.py'
--- a/bzrlib/tests/script.py 2010-10-13 07:55:13 +0000
+++ b/bzrlib/tests/script.py 2010-10-20 12:06:13 +0000
@@ -28,7 +28,6 @@
from cStringIO import StringIO
from bzrlib import (
- commands,
errors,
osutils,
tests,
@@ -514,31 +513,3 @@
"""Run the given script within a testcase"""
return ScriptRunner().run_script(test_case, script_string)
-
-class cmd_test_script(commands.Command):
- """Run a shell-like test from a file."""
-
- hidden = True
- takes_args = ['infile']
-
- @commands.display_command
- def run(self, infile):
-
- f = open(infile)
- try:
- script = f.read()
- finally:
- f.close()
-
- class Test(TestCaseWithTransportAndScript):
-
- script = None # Set before running
-
- def test_it(self):
- self.run_script(script)
-
- runner = tests.TextTestRunner(stream=self.outf)
- test = Test('test_it')
- test.path = os.path.realpath(infile)
- res = runner.run(test)
- return len(res.errors) + len(res.failures)
=== modified file 'bzrlib/tests/test_import_tariff.py'
--- a/bzrlib/tests/test_import_tariff.py 2010-06-17 16:54:26 +0000
+++ b/bzrlib/tests/test_import_tariff.py 2010-10-20 11:16:16 +0000
@@ -109,3 +109,9 @@
# loading wt-specific stuff
#
# See https://bugs.launchpad.net/bzr/+bug/553017
+
+ def test_help_commands(self):
+ # See https://bugs.launchpad.net/bzr/+bug/663773
+ self.run_command_check_imports(['help', 'commands'], [
+ 'testtools',
+ ])
More information about the bazaar-commits
mailing list