From d9f0a876a0ec1c5320d77b0b4314bbd4a5b11bd3 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 19 Sep 2013 19:09:00 +0100 Subject: Match IMPLEMENTS always case-insensitively Reported-by: Jannis Pohlmann --- yarn | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'yarn') diff --git a/yarn b/yarn index 501d10e..f4abcdc 100755 --- a/yarn +++ b/yarn @@ -204,7 +204,7 @@ class YarnRunner(cliapp.Application): def connect_implementation(self, scenario, step, implementations): matching = [i for i in implementations if step.what == i.what and - re.match('(%s)$' % i.regexp, step.text, re.I)] + self.implements_matches_step(i, step)] if len(matching) == 0: raise cliapp.AppException( @@ -371,7 +371,7 @@ class YarnRunner(cliapp.Application): self.ts['step_name'] = '%s %s' % (step.what, step.text) self.steps_run += 1 - m = re.match(step.implementation.regexp, step.text) + m = self.implements_matches_step(step.implementation, step) assert m is not None env = self.clean_env() env['DATADIR'] = datadir @@ -439,6 +439,18 @@ class YarnRunner(cliapp.Application): nice = ''.join(nice) return nice + def implements_matches_step(self, implements, step): + '''Return re.Match if implements matches the step. + + Otherwise, return None. + + ''' + + m = re.match(implements.regexp, step.text, re.I) + if m and m.end() != len(step.text): + return None + return m + def indent(self, s): return ''.join(' %s\n' % line for line in s.splitlines()) -- cgit v1.2.1