diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-10-27 20:39:39 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-10-27 20:40:10 +0200 |
commit | 2bd060daaf3b73af6461c0601088c274d947b302 (patch) | |
tree | 2c35fb075c112e82e0ec3c96468937cfa4032f15 | |
parent | 2b2583ff49e5c29f0a53405c7392e5fbaf6f0652 (diff) | |
download | cmdtest-2bd060daaf3b73af6461c0601088c274d947b302.tar.gz |
Implement EXAMLE blocks
-rw-r--r-- | simple.scenario | 6 | ||||
-rw-r--r-- | yarnlib/block_parser.py | 5 | ||||
-rw-r--r-- | yarnlib/block_parser_tests.py | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/simple.scenario b/simple.scenario index 9391cf1..5beed80 100644 --- a/simple.scenario +++ b/simple.scenario @@ -17,6 +17,12 @@ The following is the actual test in this scenario: We also support some non-ASCII text: älämölö. +We can have code examples: + + EXAMPLE this is a code example + This is NOT a scenario! + This is just ignored. + And the implementations follow. IMPLEMENTS GIVEN a clean slate diff --git a/yarnlib/block_parser.py b/yarnlib/block_parser.py index db99b31..df95fb2 100644 --- a/yarnlib/block_parser.py +++ b/yarnlib/block_parser.py @@ -44,6 +44,7 @@ class BlockParser(object): 'AND': self.parse_and, '...': self.parse_continuation, 'IMPLEMENTS': self.parse_implementing, + 'EXAMPLE': self.parse_example, } def parse_blocks(self, blocks): @@ -148,3 +149,7 @@ class BlockParser(object): self.implementations.append(implementation) return blocks + def parse_example(self, line, blocks): + if blocks: + del blocks[0] + return blocks diff --git a/yarnlib/block_parser_tests.py b/yarnlib/block_parser_tests.py index 689a197..ead8a31 100644 --- a/yarnlib/block_parser_tests.py +++ b/yarnlib/block_parser_tests.py @@ -30,6 +30,10 @@ class BlockParserTests(unittest.TestCase): self.assertEqual(self.parser.scenarios, []) self.assertEqual(self.parser.implementations, []) + def test_skips_examples(self): + self.parser.parse_blocks(['EXAMPLE foo', 'bar']) + self.assertEqual(len(self.parser.scenarios), 0) + def test_parses_simple_elements(self): self.parser.parse_blocks( ['SCENARIO foo', 'ASSUMING something', 'GIVEN bar', |