From d89b53bdce42ffe4b91e66c9abeb2458d48361bb Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 25 Aug 2013 22:38:56 +1200 Subject: * Most filters will now accept a file path argument instead of only reading from stdin. (Robert Collins, #409206) --- python/subunit/tests/__init__.py | 2 ++ python/subunit/tests/test_filters.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 python/subunit/tests/test_filters.py (limited to 'python/subunit/tests') diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py index 3552eff..a3caa38 100644 --- a/python/subunit/tests/__init__.py +++ b/python/subunit/tests/__init__.py @@ -19,6 +19,7 @@ from unittest import TestLoader from subunit.tests import ( test_chunked, test_details, + test_filters, test_progress_model, test_run, test_subunit_filter, @@ -34,6 +35,7 @@ def test_suite(): loader = TestLoader() result = loader.loadTestsFromModule(test_chunked) result.addTest(loader.loadTestsFromModule(test_details)) + result.addTest(loader.loadTestsFromModule(test_filters)) result.addTest(loader.loadTestsFromModule(test_progress_model)) result.addTest(loader.loadTestsFromModule(test_test_results)) result.addTest(loader.loadTestsFromModule(test_test_protocol)) diff --git a/python/subunit/tests/test_filters.py b/python/subunit/tests/test_filters.py new file mode 100644 index 0000000..0a5e7c7 --- /dev/null +++ b/python/subunit/tests/test_filters.py @@ -0,0 +1,35 @@ +# +# subunit: extensions to Python unittest to get test results from subprocesses. +# Copyright (C) 2013 Robert Collins +# +# 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 sys +from tempfile import NamedTemporaryFile + +from testtools import TestCase + +from subunit.filters import find_stream + + +class TestFindStream(TestCase): + + def test_no_argv(self): + self.assertEqual('foo', find_stream('foo', [])) + + def test_opens_file(self): + f = NamedTemporaryFile() + f.write(b'foo') + f.flush() + stream = find_stream('bar', [f.name]) + self.assertEqual(b'foo', stream.read()) -- cgit v1.2.1