Commits

Olemis Lang committed 32f4398

BH Multiproduct #387 : Execute in default product test cases marked with BH_IN_DEFAULT_PRODUCT flag

  • Participants
  • Parent commits 7dfe878
  • Branches t387_test_functional

Comments (0)

Files changed (1)

File t387/t387_r1485255_functional_test_infra.diff

 
 diff -r ab4d5983c6ca bloodhound_multiproduct/tests/functional/__init__.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/bloodhound_multiproduct/tests/functional/__init__.py	Mon Jun 10 21:28:31 2013 -0500
-@@ -0,0 +1,677 @@
++++ b/bloodhound_multiproduct/tests/functional/__init__.py	Tue Jun 11 01:55:29 2013 -0500
+@@ -0,0 +1,715 @@
 +# -*- coding: utf-8 -*-
 +#
 +#  Licensed to the Apache Software Foundation (ASF) under one
 +#  under the License.
 +
 +import imp
++from inspect import isclass
 +import os
 +from subprocess import call, Popen
 +import sys
 +from multiproduct.api import MultiProductSystem
 +from multiproduct import hooks
 +
++from tests import unittest
++
 +#----------------
 +# Product-aware classes for functional tests
 +#----------------
 +            self._tester.default_product_url = default_product_base()
 +            print "Started web server: %s" % self._testenv.url
 +
++    def run(self, result):
++        """Setup the fixture (self.setUp), call .setFixture on all the tests,
++        and tear down the fixture (self.tearDown).
++
++        Ensure marked tests will be wrapped by specialized context manager in
++        order access default product URL namespace instead of global.
++        """
++        self.setUp()
++        if hasattr(self, 'fixture'):
++            for test in self._tests:
++                if hasattr(test, 'setFixture'):
++                    test.setFixture(self.fixture)
++        # Override unittest loop
++        for test in self._tests:
++            if result.shouldStop:
++                break
++            if getattr(test, 'BH_IN_DEFAULT_PRODUCT', False) and \
++                    hasattr(self._tester, 'in_defaut_product'):
++                with self._tester.in_defaut_product(self._tester):
++                    test(result)
++            else:
++                test(result)
++        self.tearDown()
++        return result
++
 +    def tearDown(self):
 +        print "\nStopping web server...\n"
 +        functional.FunctionalTestSuite.tearDown(self)
 +
++# Mark some test cases to be run against default product
++import trac.ticket.tests.functional
++import trac.admin.tests.functional
++for mdl in (trac.ticket.tests.functional, trac.admin.tests.functional):
++    for attr in dir(mdl):
++        attr = getattr(trac.ticket.tests.functional, attr)
++        if isclass(attr) and issubclass(attr, 
++                                        functional.FunctionalTwillTestCaseSetup):
++            attr.BH_IN_DEFAULT_PRODUCT = True
++del attr, mdl
 +
 +def trac_functionalSuite(suite):
 +    from trac.tests.functional import testcases
 +    unittest.main(defaultTest='test_suite')
 diff -r ab4d5983c6ca bloodhound_multiproduct/tests/functional/prefs.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/bloodhound_multiproduct/tests/functional/prefs.py	Mon Jun 10 21:28:31 2013 -0500
++++ b/bloodhound_multiproduct/tests/functional/prefs.py	Tue Jun 11 01:55:29 2013 -0500
 @@ -0,0 +1,94 @@
 +# -*- coding: utf-8 -*-
 +#
 +    unittest.main(defaultTest='functionalSuite')
 diff -r ab4d5983c6ca trac/trac/tests/functional/__init__.py
 --- a/trac/trac/tests/functional/__init__.py	Wed Jun 05 14:34:14 2013 -0500
-+++ b/trac/trac/tests/functional/__init__.py	Mon Jun 10 21:28:31 2013 -0500
++++ b/trac/trac/tests/functional/__init__.py	Tue Jun 11 01:55:29 2013 -0500
 @@ -104,6 +104,8 @@
          else:
              env_class = FunctionalTestEnvironment