summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-09 11:57:42 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-09 11:57:42 +0100
commit13826e66dd4225483019c72ff12566916dc71a67 (patch)
tree607016cd7e9c9f26d5ff430c23885c188e1eeffc
parenta91ac948b037f58217d89553fa031a18960b9623 (diff)
downloadcmdtest-13826e66dd4225483019c72ff12566916dc71a67.tar.gz
Handle an empty line in a story
-rw-r--r--yarnlib/block_parser.py4
-rw-r--r--yarnlib/block_parser_tests.py4
2 files changed, 7 insertions, 1 deletions
diff --git a/yarnlib/block_parser.py b/yarnlib/block_parser.py
index 09a7a22..b9ca24c 100644
--- a/yarnlib/block_parser.py
+++ b/yarnlib/block_parser.py
@@ -44,7 +44,9 @@ class BlockParser(object):
def parse_one(self, blocks):
assert blocks
block = blocks[0]
- assert block
+ if not block:
+ del blocks[0]
+ return
t = block.split('\n', 1)
assert len(t) in [1,2]
if len(t) == 1:
diff --git a/yarnlib/block_parser_tests.py b/yarnlib/block_parser_tests.py
index ff1feab..1576950 100644
--- a/yarnlib/block_parser_tests.py
+++ b/yarnlib/block_parser_tests.py
@@ -51,6 +51,10 @@ class BlockParserTests(unittest.TestCase):
self.parser.parse_blocks(['STORY foo bar '])
self.assertEqual(self.parser.stories[0].name, 'foo bar')
+ def test_handles_empty_line(self):
+ self.parser.parse_blocks([''])
+ self.assertEqual(self.parser.stories, [])
+
def test_parses_implements_in_a_block_by_itself(self):
self.parser.parse_blocks(['IMPLEMENTS GIVEN foo\ntrue'])
impls = self.parser.implementations