diff --git a/.gitignore b/.gitignore index 472b88947830f73d3c638289fb4a167f888af43f..78fee0a7208ce976d9d13105f02cda89979390ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.cache *.pyc bin docs/_build diff --git a/tests/module/test_parser.py b/tests/module/test_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..abadeeef65b147b8e0c903b5bb71f9f5f64eef7d --- /dev/null +++ b/tests/module/test_parser.py @@ -0,0 +1,25 @@ +from yangson.module.parser import Parser + +class TestParser: + + text = """module test { // Nice module + prefix t; + namespace /* URI follows */ \t'http://example.com/test'; + leaf foo { + type string; + default "hi \\"doc\\""; + } + leaf bar { + mandatory true; + type uint8; + } + } + """ + + def test_parser(self): + p = Parser(self.text) + s = p.parse_module() + ss = s.find_all("leaf") + sss1 = ss[0].find1("default") + sss2 = ss[1].find1("type", "uint8") + assert sss1.keyword == "default"