diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/debian/bzr-builder.manifest python-testscenarios-0.2+bzr21~ppa19~natty1/debian/bzr-builder.manifest --- python-testscenarios-0.2+bzr19~ppa19~natty1/debian/bzr-builder.manifest 2012-04-04 10:21:19.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/debian/bzr-builder.manifest 2012-04-05 10:20:24.000000000 +0000 @@ -1,3 +1,3 @@ -# bzr-builder format 0.2 deb-version {debupstream-base}bzr19~ppa19 -lp:testscenarios revid:robertc@robertcollins.net-20120404100246-n6ap8h2x14uxg144 +# bzr-builder format 0.2 deb-version {debupstream-base}bzr21~ppa19 +lp:testscenarios revid:robertc@robertcollins.net-20120404104652-fc24gv81xf46f8k7 merge packaging lp:~testing-cabal/ubuntu/natty/python-testscenarios/daily-build-packaging revid:jml@canonical.com-20101031222533-rgyyjbmxghddz7vv diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/debian/changelog python-testscenarios-0.2+bzr21~ppa19~natty1/debian/changelog --- python-testscenarios-0.2+bzr19~ppa19~natty1/debian/changelog 2012-04-04 10:21:19.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/debian/changelog 2012-04-05 10:20:24.000000000 +0000 @@ -1,8 +1,8 @@ -python-testscenarios (0.2+bzr19~ppa19~natty1) natty; urgency=low +python-testscenarios (0.2+bzr21~ppa19~natty1) natty; urgency=low * Auto build. - -- Launchpad Package Builder Wed, 04 Apr 2012 10:21:19 +0000 + -- Launchpad Package Builder Thu, 05 Apr 2012 10:20:24 +0000 python-testscenarios (0.2-1) unstable; urgency=low diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/__init__.py python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/__init__.py --- python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/__init__.py 2012-04-04 10:21:18.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/__init__.py 2012-04-05 10:20:23.000000000 +0000 @@ -38,15 +38,17 @@ # established at this point, and setup.py will use a version of next-$(revno). # If the releaselevel is 'final', then the tarball will be major.minor.micro. # Otherwise it is major.minor.micro~$(revno). -__version__ = (0, 2, 0, 'final', 0) +__version__ = (0, 3, 0, 'final', 0) __all__ = [ 'TestWithScenarios', + 'WithScenarios', 'apply_scenario', 'apply_scenarios', 'generate_scenarios', 'load_tests_apply_scenarios', 'multiply_scenarios', + 'per_module_scenarios', ] @@ -57,8 +59,9 @@ generate_scenarios, load_tests_apply_scenarios, multiply_scenarios, + per_module_scenarios, ) -from testscenarios.testcase import TestWithScenarios +from testscenarios.testcase import TestWithScenarios, WithScenarios def test_suite(): diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/testcase.py python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/testcase.py --- python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/testcase.py 2012-04-04 10:21:18.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/testcase.py 2012-04-05 10:20:23.000000000 +0000 @@ -16,6 +16,7 @@ __all__ = [ 'TestWithScenarios', + 'WithScenarios', ] import unittest @@ -24,16 +25,18 @@ from testscenarios.scenarios import generate_scenarios -class TestWithScenarios(unittest.TestCase): - """A TestCase with support for scenarios via a scenarios attribute. - - When a test object which is an instance of TestWithScenarios is run, - and there is a non-empty scenarios attribute on the object, the test is - multiplied by the run method into one test per scenario. For this to work - reliably the TestWithScenarios.run method must not be overriden in a - subclass (or overridden compatibly with TestWithScenarios). +_doc = """ + When a test object which inherits from WithScenarios is run, and there is a + non-empty scenarios attribute on the object, the test is multiplied by the + run method into one test per scenario. For this to work reliably the + WithScenarios.run method must not be overriden in a subclass (or overridden + compatibly with WithScenarios). """ +class WithScenarios(object): + __doc__ = """A mixin for TestCase with support for declarative scenarios. + """ + _doc + def _get_scenarios(self): return getattr(self, 'scenarios', None) @@ -50,7 +53,7 @@ for test in generate_scenarios(self): test.debug() else: - return super(TestWithScenarios, self).debug() + return super(WithScenarios, self).debug() def run(self, result=None): scenarios = self._get_scenarios() @@ -59,4 +62,9 @@ test.run(result) return else: - return super(TestWithScenarios, self).run(result) + return super(WithScenarios, self).run(result) + + +class TestWithScenarios(WithScenarios, unittest.TestCase): + __doc__ = """Unittest TestCase with support for declarative scenarios. + """ + _doc diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/tests/__init__.py python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/tests/__init__.py --- python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/tests/__init__.py 2012-04-04 10:21:18.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/tests/__init__.py 2012-04-05 10:20:23.000000000 +0000 @@ -40,4 +40,4 @@ doctest.set_unittest_reportflags(doctest.REPORT_ONLY_FIRST_FAILURE) standard_tests.addTest( doctest.DocFileSuite("../../../README", optionflags=doctest.ELLIPSIS)) - return standard_tests + return loader.suiteClass(testscenarios.generate_scenarios(standard_tests)) diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/tests/test_testcase.py python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/tests/test_testcase.py --- python-testscenarios-0.2+bzr19~ppa19~natty1/lib/testscenarios/tests/test_testcase.py 2012-04-04 10:21:18.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/lib/testscenarios/tests/test_testcase.py 2012-04-05 10:20:23.000000000 +0000 @@ -17,13 +17,25 @@ import unittest import testscenarios +import testtools from testtools.tests.helpers import LoggingResult -class TestTestWithScenarios(unittest.TestCase): +class TestTestWithScenarios(testtools.TestCase): + + scenarios = testscenarios.scenarios.per_module_scenarios( + 'impl', (('unittest', 'unittest'), ('unittest2', 'unittest2'))) + + @property + def Implementation(self): + if isinstance(self.impl, tuple): + self.skipTest('import failed - module not installed?') + class Implementation(testscenarios.WithScenarios, self.impl.TestCase): + pass + return Implementation def test_no_scenarios_no_error(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): def test_pass(self): pass test = ReferenceTest("test_pass") @@ -33,7 +45,7 @@ self.assertEqual(1, result.testsRun) def test_with_one_scenario_one_run(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [('demo', {})] def test_pass(self): pass @@ -48,7 +60,7 @@ log[0][1].id()) def test_with_two_scenarios_two_run(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [('1', {}), ('2', {})] def test_pass(self): pass @@ -66,7 +78,7 @@ log[4][1].id()) def test_attributes_set(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [ ('1', {'foo': 1, 'bar': 2}), ('2', {'foo': 2, 'bar': 4})] @@ -80,7 +92,7 @@ self.assertEqual(2, result.testsRun) def test_scenarios_attribute_cleared(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [ ('1', {'foo': 1, 'bar': 2}), ('2', {'foo': 2, 'bar': 4})] @@ -97,14 +109,14 @@ self.assertEqual(None, log[4][1].scenarios) def test_countTestCases_no_scenarios(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): def test_check_foo(self): pass test = ReferenceTest("test_check_foo") self.assertEqual(1, test.countTestCases()) def test_countTestCases_empty_scenarios(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [] def test_check_foo(self): pass @@ -112,7 +124,7 @@ self.assertEqual(1, test.countTestCases()) def test_countTestCases_1_scenarios(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [('1', {'foo': 1, 'bar': 2})] def test_check_foo(self): pass @@ -120,7 +132,7 @@ self.assertEqual(1, test.countTestCases()) def test_countTestCases_2_scenarios(self): - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [ ('1', {'foo': 1, 'bar': 2}), ('2', {'foo': 2, 'bar': 4})] @@ -131,7 +143,7 @@ def test_debug_2_scenarios(self): log = [] - class ReferenceTest(testscenarios.TestWithScenarios): + class ReferenceTest(self.Implementation): scenarios = [ ('1', {'foo': 1, 'bar': 2}), ('2', {'foo': 2, 'bar': 4})] diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/NEWS python-testscenarios-0.2+bzr21~ppa19~natty1/NEWS --- python-testscenarios-0.2+bzr19~ppa19~natty1/NEWS 2012-04-04 10:21:18.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/NEWS 2012-04-05 10:20:23.000000000 +0000 @@ -6,15 +6,22 @@ IN DEVELOPMENT ~~~~~~~~~~~~~~ -0.2 +0.3 ~~~ -NEW FEATURES: +CHANGES: * New function ``per_module_scenarios`` for tests that should be applied across multiple modules providing the same interface, some of which may not be available at run time. (Martin Pool) +* ``TestWithScenarios`` is now backed by a mixin - WithScenarios - which can be + mixed into different unittest implementations more cleanly (e.g. unittest2). + (James Polley, Robert Collins) + +0.2 +~~~ + CHANGES: * Adjust the cloned tests ``shortDescription`` if one is present. (Ben Finney) diff -Nru python-testscenarios-0.2+bzr19~ppa19~natty1/setup.py python-testscenarios-0.2+bzr21~ppa19~natty1/setup.py --- python-testscenarios-0.2+bzr19~ppa19~natty1/setup.py 2012-04-04 10:21:18.000000000 +0000 +++ python-testscenarios-0.2+bzr21~ppa19~natty1/setup.py 2012-04-05 10:20:23.000000000 +0000 @@ -6,7 +6,7 @@ description = file(os.path.join(os.path.dirname(__file__), 'README'), 'rb').read() setup(name="testscenarios", - version="0.2", + version="0.3", description="Testscenarios, a pyunit extension for dependency injection", long_description=description, maintainer="Robert Collins",