Expose ParseContext::ignore_keyword() in Python

This commit is contained in:
Joakim Hove
2021-03-02 10:24:18 +01:00
parent 6d04924966
commit 0c74e9ac7a
2 changed files with 17 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ void python::common::export_ParseContext(py::module& module) {
py::class_< ParseContext >(module, "ParseContext" )
.def(py::init<>())
.def(py::init<const std::vector<std::pair<std::string, InputError::Action>>>())
.def( "ignore_keyword", &ParseContext::ignoreKeyword )
.def( "update", ctx_update );
py::enum_< InputError::Action >( module, "action" )

View File

@@ -84,6 +84,22 @@ FIPNUM
self.assertEqual(112, es.grid().ny)
self.assertEqual(22, es.grid().nz)
def test_parse_ignore_keyword(self):
deck_string = """
FIPNUM
100*1 100*2 /
KEYWORD
1 2 3 /
"""
parse_context = ParseContext( )
parser = Parser()
parse_context.ignore_keyword("KEYWORD")
deck = parser.parse_string( deck_string, parse_context )
self.assertEqual(len(deck), 1)
if __name__ == "__main__":
unittest.main()