diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-06-09 12:09:06 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-06-09 12:09:06 +0100 |
commit | 0f367f13c234495e5f448fe3e42d38ede10400b5 (patch) | |
tree | f4e3f45808aaeae60ae738be7461a2d9126b964a | |
parent | a6c8b66d4c8bc4138dae2a8872b8fa879d1eb2f1 (diff) | |
download | cmdtest-0f367f13c234495e5f448fe3e42d38ede10400b5.tar.gz |
Add tests for bad IMPLEMENTS lines
-rw-r--r-- | yarnlib/block_parser.py | 2 | ||||
-rw-r--r-- | yarnlib/block_parser_tests.py | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/yarnlib/block_parser.py b/yarnlib/block_parser.py index 73d6178..1a600ee 100644 --- a/yarnlib/block_parser.py +++ b/yarnlib/block_parser.py @@ -113,7 +113,7 @@ class BlockParser(object): words = line.split() if len(words) < 2: raise BlockError( - 'Syntax error: IMPLEMENTING must have what and regexp') + 'Syntax error: IMPLEMENTS must have what and regexp') what = words[0] regexp = ' '.join(words[1:]) if blocks: diff --git a/yarnlib/block_parser_tests.py b/yarnlib/block_parser_tests.py index 0a1d441..7051e17 100644 --- a/yarnlib/block_parser_tests.py +++ b/yarnlib/block_parser_tests.py @@ -104,3 +104,21 @@ class BlockParserTests(unittest.TestCase): self.assertEqual(impls[1].regexp, 'bar') self.assertEqual(impls[1].shell, 'cat /dev/null') + def test_raises_error_for_implements_with_no_args(self): + self.assertRaises( + yarnlib.BlockError, + self.parser.parse_blocks, + ['IMPLEMENTS']) + + def test_raises_error_for_implements_with_one_args(self): + self.assertRaises( + yarnlib.BlockError, + self.parser.parse_blocks, + ['IMPLEMENTS GIVEN']) + + def test_raises_error_for_implements_with_first_args_not_a_keyword(self): + self.assertRaises( + yarnlib.BlockError, + self.parser.parse_blocks, + ['IMPLEMENTS foo']) + |