diff options
| author | Robert Collins <robertc@robertcollins.net> | 2013-06-16 22:28:11 +1200 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2013-06-16 22:28:11 +1200 |
| commit | bf8e1ee6e053c12ebfbdebd48954af695948c492 (patch) | |
| tree | 6250d0ef889471cbbf78b999d36df92a3ca25ca9 /python | |
| parent | 12bcba4d055d8cede155976cba1acb8a5a7f2994 (diff) | |
| download | subunit-git-bf8e1ee6e053c12ebfbdebd48954af695948c492.tar.gz | |
BUG FIXES
~~~~~~~~~
* Removed GPL files that were (C) non Subunit Developers - they are
incompatible for binary distribution, which affects redistributors.
(Robert Collins, #1185591)
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/tests/TestUtil.py | 80 | ||||
| -rw-r--r-- | python/subunit/tests/__init__.py | 27 | ||||
| -rw-r--r-- | python/subunit/tests/test_chunked.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_details.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_progress_model.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_run.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_subunit_filter.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_subunit_stats.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_subunit_tags.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_tap2subunit.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol2.py | 6 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_results.py | 6 |
13 files changed, 14 insertions, 159 deletions
diff --git a/python/subunit/tests/TestUtil.py b/python/subunit/tests/TestUtil.py deleted file mode 100644 index 39d901e..0000000 --- a/python/subunit/tests/TestUtil.py +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright (c) 2004 Canonical Limited -# Author: Robert Collins <robert.collins@canonical.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -import sys -import logging -import unittest - - -class LogCollector(logging.Handler): - def __init__(self): - logging.Handler.__init__(self) - self.records=[] - def emit(self, record): - self.records.append(record.getMessage()) - - -def makeCollectingLogger(): - """I make a logger instance that collects its logs for programmatic analysis - -> (logger, collector)""" - logger=logging.Logger("collector") - handler=LogCollector() - handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) - logger.addHandler(handler) - return logger, handler - - -def visitTests(suite, visitor): - """A foreign method for visiting the tests in a test suite.""" - for test in suite._tests: - #Abusing types to avoid monkey patching unittest.TestCase. - # Maybe that would be better? - try: - test.visit(visitor) - except AttributeError: - if isinstance(test, unittest.TestCase): - visitor.visitCase(test) - elif isinstance(test, unittest.TestSuite): - visitor.visitSuite(test) - visitTests(test, visitor) - else: - print ("unvisitable non-unittest.TestCase element %r (%r)" % (test, test.__class__)) - - -class TestSuite(unittest.TestSuite): - """I am an extended TestSuite with a visitor interface. - This is primarily to allow filtering of tests - and suites or - more in the future. An iterator of just tests wouldn't scale...""" - - def visit(self, visitor): - """visit the composite. Visiting is depth-first. - current callbacks are visitSuite and visitCase.""" - visitor.visitSuite(self) - visitTests(self, visitor) - - -class TestLoader(unittest.TestLoader): - """Custome TestLoader to set the right TestSuite class.""" - suiteClass = TestSuite - -class TestVisitor(object): - """A visitor for Tests""" - def visitSuite(self, aTestSuite): - pass - def visitCase(self, aTestCase): - pass diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py index 4275229..3552eff 100644 --- a/python/subunit/tests/__init__.py +++ b/python/subunit/tests/__init__.py @@ -14,8 +14,9 @@ # limitations under that license. # +from unittest import TestLoader + from subunit.tests import ( - TestUtil, test_chunked, test_details, test_progress_model, @@ -30,16 +31,16 @@ from subunit.tests import ( ) def test_suite(): - result = TestUtil.TestSuite() - result.addTest(test_chunked.test_suite()) - result.addTest(test_details.test_suite()) - result.addTest(test_progress_model.test_suite()) - result.addTest(test_test_results.test_suite()) - result.addTest(test_test_protocol.test_suite()) - result.addTest(test_test_protocol2.test_suite()) - result.addTest(test_tap2subunit.test_suite()) - result.addTest(test_subunit_filter.test_suite()) - result.addTest(test_subunit_tags.test_suite()) - result.addTest(test_subunit_stats.test_suite()) - result.addTest(test_run.test_suite()) + loader = TestLoader() + result = loader.loadTestsFromModule(test_chunked) + result.addTest(loader.loadTestsFromModule(test_details)) + result.addTest(loader.loadTestsFromModule(test_progress_model)) + result.addTest(loader.loadTestsFromModule(test_test_results)) + 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_subunit_filter)) + result.addTest(loader.loadTestsFromModule(test_subunit_tags)) + result.addTest(loader.loadTestsFromModule(test_subunit_stats)) + result.addTest(loader.loadTestsFromModule(test_run)) return result diff --git a/python/subunit/tests/test_chunked.py b/python/subunit/tests/test_chunked.py index e0742f1..5100b32 100644 --- a/python/subunit/tests/test_chunked.py +++ b/python/subunit/tests/test_chunked.py @@ -22,12 +22,6 @@ from testtools.compat import _b, BytesIO import subunit.chunked -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result - - class TestDecode(unittest.TestCase): def setUp(self): diff --git a/python/subunit/tests/test_details.py b/python/subunit/tests/test_details.py index 746aa04..8605c5a 100644 --- a/python/subunit/tests/test_details.py +++ b/python/subunit/tests/test_details.py @@ -22,12 +22,6 @@ import subunit.tests from subunit import content, content_type, details -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result - - class TestSimpleDetails(unittest.TestCase): def test_lineReceived(self): diff --git a/python/subunit/tests/test_progress_model.py b/python/subunit/tests/test_progress_model.py index 76200c6..2ca0888 100644 --- a/python/subunit/tests/test_progress_model.py +++ b/python/subunit/tests/test_progress_model.py @@ -110,9 +110,3 @@ class TestProgressModel(unittest.TestCase): progress.advance() progress.pop() self.assertProgressSummary(1, 3, progress) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_run.py b/python/subunit/tests/test_run.py index 209185d..0ca5a51 100644 --- a/python/subunit/tests/test_run.py +++ b/python/subunit/tests/test_run.py @@ -24,12 +24,6 @@ import subunit from subunit.run import SubunitTestRunner -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result - - class TestSubunitTestRunner(unittest.TestCase): def test_includes_timing_output(self): diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py index c28ca33..5f34b3b 100644 --- a/python/subunit/tests/test_subunit_filter.py +++ b/python/subunit/tests/test_subunit_filter.py @@ -344,9 +344,3 @@ class TestFilterCommand(TestCase): stream = StreamResultToBytes(byte_stream) stream.status(file_name="stdout", file_bytes=b'hi thar') self.assertEqual(byte_stream.getvalue(), output) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_subunit_stats.py b/python/subunit/tests/test_subunit_stats.py index 6fd3301..7c5e42d 100644 --- a/python/subunit/tests/test_subunit_stats.py +++ b/python/subunit/tests/test_subunit_stats.py @@ -76,9 +76,3 @@ Seen tags: global, local self.setUpUsedStream() self.result.formatStats() self.assertEqual(expected, self.output.getvalue()) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_subunit_tags.py b/python/subunit/tests/test_subunit_tags.py index e8d8c3a..17a5839 100644 --- a/python/subunit/tests/test_subunit_tags.py +++ b/python/subunit/tests/test_subunit_tags.py @@ -62,9 +62,3 @@ class TestSubUnitTags(unittest.TestCase): self.assertEqual( 0, subunit.tag_stream(self.original, self.filtered, ["-bar"])) self.assertEqual(reference.getvalue(), self.filtered.getvalue()) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_tap2subunit.py b/python/subunit/tests/test_tap2subunit.py index f689946..5b7c07a 100644 --- a/python/subunit/tests/test_tap2subunit.py +++ b/python/subunit/tests/test_tap2subunit.py @@ -385,9 +385,3 @@ class TestTAP2SubUnit(TestCase): eventstream = StreamResult() subunit.ByteStreamToStreamResult(self.subunit).run(eventstream) self.assertEqual(events, eventstream._events) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 7831ba1..dc2c318 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -1329,9 +1329,3 @@ class TestTestProtocolClient(unittest.TestCase): def test_tags_gone(self): self.protocol.tags(set(), set(['bar'])) self.assertEqual(_b("tags: -bar\n"), self.io.getvalue()) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py index 583c550..0014539 100644 --- a/python/subunit/tests/test_test_protocol2.py +++ b/python/subunit/tests/test_test_protocol2.py @@ -415,9 +415,3 @@ class TestByteStreamToStreamResult(TestCase): file_bytes=b'foo') self.check_event(content.getvalue(), test_id=None, file_name='bar', route_code='0', mime_type='text/plain', file_bytes=b'foo') - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py index ff74b9a..44f95b3 100644 --- a/python/subunit/tests/test_test_results.py +++ b/python/subunit/tests/test_test_results.py @@ -564,9 +564,3 @@ class TestCsvResult(testtools.TestCase): stream = StringIO() subunit.test_results.CsvResult(stream) self.assertEqual([], self.parse_stream(stream)) - - -def test_suite(): - loader = subunit.tests.TestUtil.TestLoader() - result = loader.loadTestsFromName(__name__) - return result |
