diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-06-09 12:04:17 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-06-09 12:04:17 +0100 |
commit | 784e8f70e7c95c202937f0403600c44dafd029f6 (patch) | |
tree | aeb3bb0f3827dbab884289bf7aed8ec009faf2d6 /yarnlib/block_parser.py | |
parent | 7ce156c74927ae99d9f824ce91183b126f7549e9 (diff) | |
download | cmdtest-784e8f70e7c95c202937f0403600c44dafd029f6.tar.gz |
Add test for wrong keyword
Diffstat (limited to 'yarnlib/block_parser.py')
-rw-r--r-- | yarnlib/block_parser.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/yarnlib/block_parser.py b/yarnlib/block_parser.py index 09a7a22..73d6178 100644 --- a/yarnlib/block_parser.py +++ b/yarnlib/block_parser.py @@ -16,9 +16,16 @@ # =*= License: GPL-3+ =*= +import cliapp + import yarnlib +class BlockError(cliapp.AppException): + + pass + + # Parse a sequence of textual blocks into Story and Implementation # objects, and their constituent objects. @@ -66,7 +73,7 @@ class BlockParser(object): if words[0] == keyword: return self.line_parsers[keyword](rest, blocks) - raise StoryTestSyntaxError("Syntax error: unknown step: %s" % line1) + raise BlockError("Syntax error: unknown step: %s" % line1) def parse_story(self, line, blocks): self.stories.append(yarnlib.Story(line)) @@ -74,7 +81,7 @@ class BlockParser(object): def parse_simple(self, what, line, blocks): if not self.stories: - raise StoryTestSyntaxError('Syntax errror: %s before STORY' % what) + raise BlockError('Syntax errror: %s before STORY' % what) step = yarnlib.StoryStep(what, line) self.stories[-1].steps.append(step) return blocks @@ -93,10 +100,10 @@ class BlockParser(object): def parse_and(self, line, blocks): if not self.stories: - raise StoryTestSyntaxError('Syntax errror: AND before STORY') + raise BlockError('Syntax errror: AND before STORY') story = self.stories[-1] if not story.steps: - raise StoryTestSyntaxError( + raise BlockError( 'Syntax errror: AND before what it would continue') step = story.steps[-1] assert step.what in self.line_parsers @@ -105,7 +112,7 @@ class BlockParser(object): def parse_implementing(self, line, blocks): words = line.split() if len(words) < 2: - raise StoryTestSyntaxError( + raise BlockError( 'Syntax error: IMPLEMENTING must have what and regexp') what = words[0] regexp = ' '.join(words[1:]) |