summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2011-11-01 11:39:51 -0400
committerJonathan Lange <jml@canonical.com>2011-11-01 11:39:51 -0400
commit25c82c64812e8e031fa3500c3fae5aa650e248cb (patch)
treed78396b525369b1dd05793056d09d207fd024e66
parenta7a909c61b8c45ada02f41a27e2f30f66e880892 (diff)
downloadtestrepository-git-25c82c64812e8e031fa3500c3fae5aa650e248cb.tar.gz
Put output_summary in the UI interface.
-rw-r--r--testrepository/tests/test_ui.py6
-rw-r--r--testrepository/ui/__init__.py15
-rw-r--r--testrepository/ui/cli.py4
-rw-r--r--testrepository/ui/decorator.py3
-rw-r--r--testrepository/ui/model.py3
5 files changed, 31 insertions, 0 deletions
diff --git a/testrepository/tests/test_ui.py b/testrepository/tests/test_ui.py
index da513ac..51dd6d4 100644
--- a/testrepository/tests/test_ui.py
+++ b/testrepository/tests/test_ui.py
@@ -129,6 +129,12 @@ class TestUIContract(ResourcedTestCase):
ui = self.get_test_ui()
ui.output_values([('foo', 1), ('bar', 'quux')])
+ def test_output_summary(self):
+ # output_summary can be called, takes success boolean and list of
+ # things to output.
+ ui = self.get_test_ui()
+ ui.output_summary(True, [('tests', 1, None), ('successes', 1, None)])
+
def test_set_command(self):
# All ui objects can be given their command.
ui = self.ui_factory()
diff --git a/testrepository/ui/__init__.py b/testrepository/ui/__init__.py
index 7df5bf2..b608a61 100644
--- a/testrepository/ui/__init__.py
+++ b/testrepository/ui/__init__.py
@@ -140,6 +140,21 @@ class AbstractUI(object):
"""
raise NotImplementedError(self.output_values)
+ def output_summary(self, successful, values):
+ """Output a summary of a test run.
+
+ An example summary might look like:
+ Run 565 (+2) tests in 2.968s
+ FAILED (errors=13 (-2), succeesses=31 (+2))
+
+ :param successful: A boolean indicating whether the result was
+ successful.
+ :param values: A dict mapping from name (e.g. "successes") to a tuple
+ of ``(value, delta)``. e.g. (31, -2)
+
+ """
+ raise NotImplementedError(self.output_summary)
+
def set_command(self, cmd):
"""Inform the UI what command it is running.
diff --git a/testrepository/ui/cli.py b/testrepository/ui/cli.py
index 9d3da20..1e49e38 100644
--- a/testrepository/ui/cli.py
+++ b/testrepository/ui/cli.py
@@ -134,6 +134,10 @@ class UI(ui.AbstractUI):
outputs.append('%s=%s' % (label, value))
self._stdout.write('%s\n' % ', '.join(outputs))
+ def output_summary(self, successful, values):
+ # XXX: Actually implement this properly.
+ pass
+
def _check_cmd(self):
parser = OptionParser()
parser.add_option("-d", "--here", dest="here",
diff --git a/testrepository/ui/decorator.py b/testrepository/ui/decorator.py
index 5cd3128..ba89606 100644
--- a/testrepository/ui/decorator.py
+++ b/testrepository/ui/decorator.py
@@ -83,6 +83,9 @@ class UI(ui.AbstractUI):
def output_values(self, values):
return self._decorated.output_values(values)
+ def output_summary(self, successful, values):
+ return self._decorated.output_summary(successful, values)
+
def set_command(self, cmd):
self.cmd = cmd
result = True
diff --git a/testrepository/ui/model.py b/testrepository/ui/model.py
index de2a0f1..e8ac43d 100644
--- a/testrepository/ui/model.py
+++ b/testrepository/ui/model.py
@@ -161,6 +161,9 @@ class UI(ui.AbstractUI):
def output_values(self, values):
self.outputs.append(('values', values))
+ def output_summary(self, successful, values):
+ self.outputs.append(('summary', successful, values))
+
def subprocess_Popen(self, *args, **kwargs):
# Really not an output - outputs should be renamed to events.
self.outputs.append(('popen', args, kwargs))