Skip to content

Commit

Permalink
refactored test class creation into appropriate method
Browse files Browse the repository at this point in the history
dexterous committed Sep 26, 2011
1 parent 5dd4072 commit f96c13e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions freshen/noseplugin.py
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ def wantDirectory(self, dirname):
def wantFile(self, filename):
return filename.endswith(".feature") or None

def _loadTestForFeature(self, feature):
def _makeTestClass(self, feature, scenario):
"""Chooses the test base class appropriate
for the given feature.
@@ -140,7 +140,7 @@ def _loadTestForFeature(self, feature):
except ImportError:
from freshen.test.pyunit import PyunitTestCase
self._test_class = PyunitTestCase
return self._test_class
return type(feature.name, (self._test_class, ), {scenario.name: lambda self: self.runScenario()})

def loadTestsFromFile(self, filename, indexes=[]):
log.debug("Loading from file %s" % filename)
@@ -165,7 +165,7 @@ def loadTestsFromFile(self, filename, indexes=[]):
for i, sc in enumerate(feat.iter_scenarios()):
if (not indexes or (i + 1) in indexes):
if self.tagmatcher.check_match(sc.tags + feat.tags):
test_class = type(feat.name, (self._loadTestForFeature(feat), ), {sc.name: lambda self: self.runScenario()})
test_class = self._makeTestClass(feat, sc)
yield test_class(StepsRunner(step_registry), step_registry, feat, sc, ctx)
cnt += 1

0 comments on commit f96c13e

Please sign in to comment.