diff options
| -rw-r--r-- | mammoth/styles/parser/document_matcher_parser.py | 4 | ||||
| -rw-r--r-- | tests/styles/parser/document_matcher_parser_tests.py | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/mammoth/styles/parser/document_matcher_parser.py b/mammoth/styles/parser/document_matcher_parser.py index 3f9687d..6d69a8f 100644 --- a/mammoth/styles/parser/document_matcher_parser.py +++ b/mammoth/styles/parser/document_matcher_parser.py @@ -1,4 +1,5 @@ from ... import documents, document_matchers +from .errors import LineParseError from .tokeniser import TokenType from .token_parser import try_parse_class_name, parse_string @@ -40,8 +41,7 @@ def parse_document_matcher(tokens): return document_matchers.comment_reference else: - # TODO: raise - pass + raise LineParseError("Unrecognised document element: {0}".format(tokens.next_value(TokenType.IDENTIFIER))) def _parse_style_name(tokens): if tokens.try_skip(TokenType.SYMBOL, "["): diff --git a/tests/styles/parser/document_matcher_parser_tests.py b/tests/styles/parser/document_matcher_parser_tests.py index 18109ca..3977cbb 100644 --- a/tests/styles/parser/document_matcher_parser_tests.py +++ b/tests/styles/parser/document_matcher_parser_tests.py @@ -2,8 +2,16 @@ from nose.tools import istest, assert_equal from mammoth import documents, document_matchers from mammoth.styles.parser.document_matcher_parser import parse_document_matcher +from mammoth.styles.parser.errors import LineParseError from mammoth.styles.parser.tokeniser import tokenise from mammoth.styles.parser.token_iterator import TokenIterator +from ...testing import assert_raises + + +@istest +def unrecognised_document_element_raises_error(): + error = assert_raises(LineParseError, lambda: read_document_matcher("x")) + assert_equal("Unrecognised document element: x", str(error)) @istest |
