Permalink
Browse files

Refactored the testcase hirarchy a bit; added experimental django-nos…

…e and django-sane-testing base classes
  • Loading branch information...
1 parent 781ee9d commit 83579e8c6fea4efeb35d12b881f9f8f34d4e8815 @rlisagor committed Sep 28, 2011
Showing with 43 additions and 30 deletions.
  1. +0 −13 freshen/test/base.py
  2. +4 −0 freshen/test/djangonose.py
  3. +17 −0 freshen/test/djangosanetesting.py
  4. +22 −17 freshen/test/pyunit.py
View
@@ -30,19 +30,6 @@ def setUp(self):
class FreshenTestCase(object):
- start_live_server = True
- database_single_transaction = True
- database_flush = True
- selenium_start = False
- no_database_interaction = False
- make_translations = True
- required_sane_plugins = ["django", "http"]
- django_plugin_started = False
- http_plugin_started = False
- last_step = None
-
- test_type = "http"
-
def __init__(self, step_runner, step_registry, feature, scenario, feature_suite):
self.feature = feature
self.scenario = scenario
@@ -0,0 +1,4 @@
+from freshen.test.pyunit import PyunitTestCase
+from django.test import TransactionTestCase
+
+DjangoNoseTestCase = make_pyunit_testcase_class(TransactionTestCase)
@@ -0,0 +1,17 @@
+from freshen.test.pyunit import PyunitTestCase
+
+class DjangoSaneTestingTestCase(PyunitTestCase):
+ """ Support testing using django-sane-testing. """
+
+ start_live_server = True
+ database_single_transaction = True
+ database_flush = True
+ selenium_start = False
+ no_database_interaction = False
+ make_translations = True
+ required_sane_plugins = ["django", "http"]
+ django_plugin_started = False
+ http_plugin_started = False
+ last_step = None
+
+ test_type = "http"
View
@@ -4,25 +4,30 @@
from unittest import TestCase
+def make_pyunit_testcase_class(base_test_case_class):
-class PyunitTestCase(FreshenTestCase, TestCase):
- """Support PyUnit tests."""
+ class _PyunitTestCase(FreshenTestCase, base_test_case_class):
+ """Support PyUnit tests."""
- def __init__(self, step_runner, step_registry, feature, scenario, feature_suite):
- FreshenTestCase.__init__(self, step_runner, step_registry,
- feature, scenario, feature_suite)
- TestCase.__init__(self, scenario.name)
+ def __init__(self, step_runner, step_registry, feature, scenario, feature_suite):
+ FreshenTestCase.__init__(self, step_runner, step_registry,
+ feature, scenario, feature_suite)
+ base_test_case_class.__init__(self, scenario.name)
- def setUp(self):
- super(PyunitTestCase, self).setUp()
- for hook_impl in self.step_registry.get_hooks('before', self.scenario.get_tags()):
- hook_impl.run(self.scenario)
+ def setUp(self):
+ super(_PyunitTestCase, self).setUp()
+ for hook_impl in self.step_registry.get_hooks('before', self.scenario.get_tags()):
+ hook_impl.run(self.scenario)
- def runScenario(self):
- for step in self.scenario.iter_steps():
- self.runStep(step, 3)
- self.last_step = None
+ def runScenario(self):
+ for step in self.scenario.iter_steps():
+ self.runStep(step, 3)
+ self.last_step = None
- def tearDown(self):
- for hook_impl in reversed(self.step_registry.get_hooks('after', self.scenario.get_tags())):
- hook_impl.run(self.scenario)
+ def tearDown(self):
+ for hook_impl in reversed(self.step_registry.get_hooks('after', self.scenario.get_tags())):
+ hook_impl.run(self.scenario)
+
+ return _PyunitTestCase
+
+PyunitTestCase = make_pyunit_testcase_class(TestCase)

0 comments on commit 83579e8

Please sign in to comment.