summaryrefslogtreecommitdiff
path: root/python/subunit/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2015-07-13 22:20:48 +1200
committerRobert Collins <robertc@robertcollins.net>2015-07-13 23:02:48 +1200
commita194e3e7cb4e5e5cd855da7eb906baaeea6cd2c2 (patch)
treec287802daae58d571c1b5a61123b4bf682bb7fad /python/subunit/tests
parent557bbf694f5cb6cb9202a1a41d9b057e7377f7ed (diff)
downloadsubunit-git-a194e3e7cb4e5e5cd855da7eb906baaeea6cd2c2.tar.gz
Add subunit2disk which exports a stream to the fs.
Diffstat (limited to 'python/subunit/tests')
-rw-r--r--python/subunit/tests/__init__.py2
-rw-r--r--python/subunit/tests/test_filter_to_disk.py49
2 files changed, 51 insertions, 0 deletions
diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py
index a62a006..c6599f7 100644
--- a/python/subunit/tests/__init__.py
+++ b/python/subunit/tests/__init__.py
@@ -31,6 +31,7 @@ from subunit.tests import (
test_chunked,
test_details,
test_filters,
+ test_filter_to_disk,
test_output_filter,
test_progress_model,
test_run,
@@ -54,6 +55,7 @@ def test_suite():
result.addTest(loader.loadTestsFromModule(test_test_protocol))
result.addTest(loader.loadTestsFromModule(test_test_protocol2))
result.addTest(loader.loadTestsFromModule(test_tap2subunit))
+ result.addTest(loader.loadTestsFromModule(test_filter_to_disk))
result.addTest(loader.loadTestsFromModule(test_subunit_filter))
result.addTest(loader.loadTestsFromModule(test_subunit_tags))
result.addTest(loader.loadTestsFromModule(test_subunit_stats))
diff --git a/python/subunit/tests/test_filter_to_disk.py b/python/subunit/tests/test_filter_to_disk.py
new file mode 100644
index 0000000..c2b0996
--- /dev/null
+++ b/python/subunit/tests/test_filter_to_disk.py
@@ -0,0 +1,49 @@
+#
+# subunit: extensions to python unittest to get test results from subprocesses.
+# Copyright (C) 2013 Subunit Contributors
+#
+# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
+# license at the users choice. A copy of both licenses are available in the
+# project source as Apache-2.0 and BSD. You may not use this file except in
+# compliance with one of these two licences.
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# license you chose for the specific language governing permissions and
+# limitations under that license.
+
+import io
+import os.path
+
+from fixtures import TempDir
+from testtools import TestCase
+from testtools.matchers import (
+ FileContains
+ )
+
+from subunit import _to_disk
+from subunit.v2 import StreamResultToBytes
+
+class SmokeTest(TestCase):
+
+ def test_smoke(self):
+ output = os.path.join(self.useFixture(TempDir()).path, 'output')
+ stdin = io.BytesIO()
+ stdout = io.StringIO()
+ writer = StreamResultToBytes(stdin)
+ writer.startTestRun()
+ writer.status(
+ 'foo', 'success', set(['tag']), file_name='fred',
+ file_bytes=b'abcdefg', eof=True, mime_type='text/plain')
+ writer.stopTestRun()
+ stdin.seek(0)
+ _to_disk.to_disk(['-d', output], stdin=stdin, stdout=stdout)
+ self.expectThat(
+ os.path.join(output, 'foo/test.json'),
+ FileContains(
+ '{"details": ["fred"], "id": "foo", "start": null, '
+ '"status": "success", "stop": null, "tags": ["tag"]}'))
+ self.expectThat(
+ os.path.join(output, 'foo/fred'),
+ FileContains('abcdefg'))