Merge lp:~allenap/commandant/test-failures-updated-bzrlib-possibly into lp:commandant

Proposed by Gavin Panella
Status: Merged
Merged at revision: 44
Proposed branch: lp:~allenap/commandant/test-failures-updated-bzrlib-possibly
Merge into: lp:commandant
Diff against target: 202 lines (+70/-53)
3 files modified
commandant/tests/test_builtins.py (+27/-18)
commandant/tests/test_controller.py (+7/-2)
commandant/tests/test_help_topics.py (+36/-33)
To merge this branch: bzr merge lp:~allenap/commandant/test-failures-updated-bzrlib-possibly
Reviewer Review Type Date Requested Status
Jamu Kakar Pending
Review via email: mp+122920@code.launchpad.net

Commit message

Be more forgiving of test output that may vary as a result of changes in dependencies.

The ordering of the standard --quiet and --verbose flags, for example, seems to have changed, possibly as a result of changes in bzrlib. This detail is irrelevant in the tests, however, so testtools.matchers.DocTestMatches is used to test output with more flexibility.

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :
Download full text (3.3 KiB)

I got a bunch of test failures here:

[ERROR]
Traceback (most recent call last):
Failure: testtools.testresult.real._StringException: ValueError: TestCase.setUp was not called. Have you upcalled all the way up the hierarchy from your setUp? e.g. Call super(HelpCommandTest, self).setUp() from your setUp().

commandant.tests.test_builtins.HelpCommandTest.test_run_commands
commandant.tests.test_builtins.HelpCommandTest.test_run_commands_with_custom_help_help_topic
commandant.tests.test_builtins.HelpCommandTest.test_run_commands_with_custom_help_topic
commandant.tests.test_builtins.HelpCommandTest.test_run_commands_without_docstring
commandant.tests.test_builtins.HelpCommandTest.test_run_hidden_commands
commandant.tests.test_builtins.HelpCommandTest.test_run_hidden_commands_without_hidden_commands
commandant.tests.test_builtins.HelpCommandTest.test_run_many_commands
commandant.tests.test_builtins.HelpCommandTest.test_run_topics
commandant.tests.test_builtins.HelpCommandTest.test_run_topics_ignores_custom_command_help
commandant.tests.test_builtins.HelpCommandTest.test_run_topics_with_custom_help_topic
commandant.tests.test_builtins.HelpCommandTest.test_run_topics_with_custom_underscore_help_topic
commandant.tests.test_builtins.HelpCommandTest.test_run_with_custom_help_text
commandant.tests.test_builtins.HelpCommandTest.test_run_with_custom_help_text_trims_trailing_whitespace
commandant.tests.test_builtins.HelpCommandTest.test_run_with_custom_topic
commandant.tests.test_builtins.HelpCommandTest.test_run_with_custom_topic_strips_whitespace
commandant.tests.test_builtins.HelpCommandTest.test_run_with_hidden_commands
commandant.tests.test_builtins.HelpCommandTest.test_run_with_python_command_topic
commandant.tests.test_builtins.HelpCommandTest.test_run_with_python_command_without_docstring
commandant.tests.test_builtins.HelpCommandTest.test_run_with_stock_help_text
commandant.tests.test_builtins.HelpCommandTest.test_run_with_unknown_command_or_topic_name
===============================================================================
[ERROR]
Traceback (most recent call last):
Failure: testtools.testresult.real._StringException: ValueError: TestCase.setUp was not called. Have you upcalled all the way up the hierarchy from your setUp? e.g. Call super(CommandHelpTopicTest, self).setUp() from your setUp().

commandant.tests.test_help_topics.CommandHelpTopicTest.test_get_help_contents
commandant.tests.test_help_topics.CommandHelpTopicTest.test_instantiate
===============================================================================
[ERROR]
Traceback (most recent call last):
Failure: testtools.testresult.real._StringException: ValueError: TestCase.setUp was not called. Have you upcalled all the way up the hierarchy from your setUp? e.g. Call super(CustomCommandHelpTopicTest, self).setUp() from your setUp().

commandant.tests.test_help_topics.CustomCommandHelpTopicTest.test_get_help_contents
-------------------------------------------------------------------------------
Ran 83 tests in 0.437s

FAILED (errors=23, successes=60)
make: *** [check] Error 1

I've fixed this by adding a new commandant.testing.basic.CommandantTestCase
class that calls the setUp...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'commandant/tests/test_builtins.py'
2--- commandant/tests/test_builtins.py 2010-06-12 13:58:13 +0000
3+++ commandant/tests/test_builtins.py 2012-09-05 18:28:21 +0000
4@@ -17,11 +17,15 @@
5
6 """Unit tests for L{commandant.builtins}."""
7
8+import doctest
9 import os
10+from textwrap import dedent
11
12 from bzrlib.commands import Command
13
14 from testresources import ResourcedTestCase
15+from testtools import TestCase
16+from testtools.matchers import DocTestMatches
17
18 from commandant import __version__
19 from commandant.builtins import (
20@@ -71,7 +75,7 @@
21 self.command.outf.getvalue().startswith("test 42.3.17\n"))
22
23
24-class HelpCommandTest(ResourcedTestCase):
25+class HelpCommandTest(ResourcedTestCase, TestCase):
26 """Tests for L{cmd_help}."""
27
28 resources = [("factory", CommandFactoryResource())]
29@@ -177,10 +181,13 @@
30
31 self.factory.create_command("fake-command", cmd_fake_command)
32 self.command.run(topic="commands")
33- self.assertEquals(self.command.outf.getvalue(), """\
34-fake-command
35-help Show help about a command or topic.
36-""")
37+ expected = dedent("""\
38+ fake-command
39+ help Show help about a command or topic.
40+ """)
41+ self.assertThat(
42+ self.command.outf.getvalue(),
43+ DocTestMatches(expected, doctest.NORMALIZE_WHITESPACE))
44
45 def test_run_commands_with_custom_help_topic(self):
46 """
47@@ -375,19 +382,21 @@
48
49 self.factory.create_command("test-command", cmd_test_command)
50 self.command.run(topic="test-command")
51- self.assertEquals(self.command.outf.getvalue(), """\
52-Purpose: A test command.
53-Usage: commandant test-command
54-
55-Options:
56- --usage Show usage message and options.
57- -v, --verbose Display more information.
58- -q, --quiet Only display errors and warnings.
59- -h, --help Show help message.
60-
61-Description:
62- This is the help text for this test command.
63-""")
64+ expected = dedent("""\
65+ Purpose: A test command.
66+ Usage: commandant test-command
67+
68+ Options:
69+ --usage Show usage message and options.
70+ ...
71+ -h, --help Show help message.
72+
73+ Description:
74+ This is the help text for this test command.
75+ """)
76+ self.assertThat(
77+ self.command.outf.getvalue(),
78+ DocTestMatches(expected, doctest.ELLIPSIS))
79
80 def test_run_with_python_command_without_docstring(self):
81 """
82
83=== modified file 'commandant/tests/test_controller.py'
84--- commandant/tests/test_controller.py 2010-06-12 13:58:13 +0000
85+++ commandant/tests/test_controller.py 2012-09-05 18:28:21 +0000
86@@ -138,8 +138,13 @@
87 self.controller.install_bzrlib_hooks()
88 self.controller.register_command("fake-command", FakeArgumentCommand)
89 self.controller.run(["fake-command", "test-arg"])
90- self.assertEquals(sys.stdout.getvalue(),
91- "((), {'test_arg': 'test-arg'})")
92+ # The argument value is sometimes be coerced into a unicode
93+ # string. Could this be a change in bzrlib?
94+ self.assertIn(
95+ sys.stdout.getvalue(), (
96+ "((), {'test_arg': 'test-arg'})",
97+ "((), {'test_arg': u'test-arg'})",
98+ ))
99
100 def test_register_help_topic(self):
101 """
102
103=== modified file 'commandant/tests/test_help_topics.py'
104--- commandant/tests/test_help_topics.py 2010-06-12 13:58:13 +0000
105+++ commandant/tests/test_help_topics.py 2012-09-05 18:28:21 +0000
106@@ -17,10 +17,13 @@
107
108 """Unit tests for L{commandant.help_topics}."""
109
110+import doctest
111 import os
112-from unittest import TestCase
113+from textwrap import dedent
114
115 from testresources import ResourcedTestCase
116+from testtools import TestCase
117+from testtools.matchers import DocTestMatches
118
119 from commandant.help_topics import (
120 HelpTopic, DocstringHelpTopic, FileHelpTopic, CommandHelpTopic)
121@@ -98,7 +101,7 @@
122 "the help topic.")
123
124
125-class CommandHelpTopicTest(ResourcedTestCase):
126+class CommandHelpTopicTest(ResourcedTestCase, TestCase):
127 """Tests for L{CommandHelpTopic}."""
128
129 resources = [("factory", CommandFactoryResource())]
130@@ -122,23 +125,23 @@
131 help_topic = CommandHelpTopic(command)
132 help_topic.controller = self.factory.controller
133 self.assertEquals(help_topic.get_summary(), "Summary text.")
134- self.assertEquals(help_topic.get_text() + "\n", """\
135-Purpose: Summary text.
136-Usage: commandant fake-command
137-
138-Options:
139- --usage Show usage message and options.
140- -v, --verbose Display more information.
141- -q, --quiet Only display errors and warnings.
142- -h, --help Show help message.
143-
144-Description:
145- Long descriptive text that
146- spans multiples lines.
147-""")
148-
149-
150-class CustomCommandHelpTopicTest(ResourcedTestCase):
151+ expected = dedent("""\
152+ Purpose: Summary text.
153+ Usage: commandant fake-command
154+
155+ Options:
156+ ...
157+
158+ Description:
159+ Long descriptive text that
160+ spans multiples lines.
161+ """)
162+ self.assertThat(
163+ help_topic.get_text() + "\n",
164+ DocTestMatches(expected, doctest.ELLIPSIS))
165+
166+
167+class CustomCommandHelpTopicTest(ResourcedTestCase, TestCase):
168 """Tests for L{CommandHelpTopic} with custom program details."""
169
170 resources = [("factory", CommandFactoryResource("test-program"))]
171@@ -153,17 +156,17 @@
172 help_topic = CommandHelpTopic(command)
173 help_topic.controller = self.factory.controller
174 self.assertEquals(help_topic.get_summary(), "Summary text.")
175- self.assertEquals(help_topic.get_text() + "\n", """\
176-Purpose: Summary text.
177-Usage: test-program fake-command
178-
179-Options:
180- --usage Show usage message and options.
181- -v, --verbose Display more information.
182- -q, --quiet Only display errors and warnings.
183- -h, --help Show help message.
184-
185-Description:
186- Long descriptive text that
187- spans multiples lines.
188-""")
189+ expected = dedent("""\
190+ Purpose: Summary text.
191+ Usage: test-program fake-command
192+
193+ Options:
194+ ...
195+
196+ Description:
197+ Long descriptive text that
198+ spans multiples lines.
199+ """)
200+ self.assertThat(
201+ help_topic.get_text() + "\n",
202+ DocTestMatches(expected, doctest.ELLIPSIS))

Subscribers

People subscribed via source and target branches