Skip to content

Commit

Permalink
Added file extension checking in loadTestsFromFile to avoid collision…
Browse files Browse the repository at this point in the history
…s with other plugins
  • Loading branch information
Kamil Grymuza committed Jul 22, 2011
1 parent 396ea19 commit bdb5530
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions freshen/noseplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,30 @@ def wantFile(self, filename):
return filename.endswith(".feature") or None

def loadTestsFromFile(self, filename, indexes=[]):
log.debug("Loading from file %s" % filename)

step_registry = StepImplRegistry(TagMatcher)
try:
feat = load_feature(filename, self.language)
path = os.path.dirname(filename)
self.impl_loader.load_steps_impl(step_registry, path, feat.use_step_defs)
except ParseException, e:
ec, ev, tb = sys.exc_info()
yield Failure(ParseException, ParseException(e.pstr, e.loc, e.msg + " in %s" % filename), tb)
return

cnt = 0
ctx = FeatureSuite()
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):
yield FreshenTestCase(StepsRunner(step_registry), step_registry, feat, sc, ctx)
cnt += 1

if not cnt:
if self.wantFile( filename ):
log.debug("Loading from file %s" % filename)

step_registry = StepImplRegistry(TagMatcher)
try:
feat = load_feature(filename, self.language)
path = os.path.dirname(filename)
self.impl_loader.load_steps_impl(step_registry, path, feat.use_step_defs)
except ParseException, e:
ec, ev, tb = sys.exc_info()
yield Failure(ParseException, ParseException(e.pstr, e.loc, e.msg + " in %s" % filename), tb)
return

cnt = 0
ctx = FeatureSuite()
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):
yield FreshenTestCase(StepsRunner(step_registry), step_registry, feat, sc, ctx)
cnt += 1

if not cnt:
yield False
else:
yield False

def loadTestsFromName(self, name, _=None):
Expand Down

0 comments on commit bdb5530

Please sign in to comment.