summaryrefslogtreecommitdiff
path: root/testrepository/ui
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2010-01-14 19:00:37 +1100
committerRobert Collins <robertc@robertcollins.net>2010-01-14 19:00:37 +1100
commit641bfc36974c673512f8bd2b5e82f55b2e6092d8 (patch)
tree77bc67c061ac35bd48bb0e7611ec9d90dfd942e6 /testrepository/ui
parenta0ec5a99b91832f96684852bce5941dd25cc759f (diff)
downloadtestrepository-git-641bfc36974c673512f8bd2b5e82f55b2e6092d8.tar.gz
Add stream output support for the UI.
Diffstat (limited to 'testrepository/ui')
-rw-r--r--testrepository/ui/__init__.py11
-rw-r--r--testrepository/ui/cli.py6
-rw-r--r--testrepository/ui/model.py3
3 files changed, 20 insertions, 0 deletions
diff --git a/testrepository/ui/__init__.py b/testrepository/ui/__init__.py
index eac93a1..d6d4339 100644
--- a/testrepository/ui/__init__.py
+++ b/testrepository/ui/__init__.py
@@ -102,6 +102,17 @@ class AbstractUI(object):
"""
raise NotImplementedError(self.output_results)
+ def output_stream(self, stream):
+ """Show a byte stream to the user.
+
+ This is not currently typed, but in future a MIME type may be
+ permitted.
+
+ :param stream: A file like object that can be read from. The UI will
+ not close the file.
+ """
+ raise NotImplementedError(self.output_results)
+
def output_table(self, table):
"""Show a table to the user.
diff --git a/testrepository/ui/cli.py b/testrepository/ui/cli.py
index 0ad4cd3..3f2ff81 100644
--- a/testrepository/ui/cli.py
+++ b/testrepository/ui/cli.py
@@ -77,6 +77,12 @@ class UI(ui.AbstractUI):
finally:
result.stopTestRun()
+ def output_stream(self, stream):
+ contents = stream.read(65536)
+ while contents:
+ self._stdout.write(contents)
+ contents = stream.read(65536)
+
def output_table(self, table):
# stringify
contents = []
diff --git a/testrepository/ui/model.py b/testrepository/ui/model.py
index 267cdd5..494c4e5 100644
--- a/testrepository/ui/model.py
+++ b/testrepository/ui/model.py
@@ -81,6 +81,9 @@ class UI(ui.AbstractUI):
def output_results(self, suite_or_test):
self.outputs.append(('results', suite_or_test))
+ def output_stream(self, stream):
+ self.outputs.append(('stream', stream))
+
def output_table(self, table):
self.outputs.append(('table', table))