def test_parseDentry(self): self.assertTrue( NameTreeParsers.parseDentry("/=>!") == Dentry( Path.empty, NameTree.Fail)) self.assertTrue( NameTreeParsers.parseDentry("/ => !") == Dentry( Path.empty, NameTree.Fail)) self.assertTrue( NameTreeParsers.parseDentry("/foo/*/bar => !") == Dentry( Dentry.Prefix( Dentry.Prefix.Label("foo"), Dentry.Prefix.AnyElem, Dentry.Prefix.Label("bar")), NameTree.Fail)) self.assertTrue( NameTreeParsers.parseDentry("/foo/bar/baz => !") == Dentry( Dentry.Prefix(Dentry.Prefix.Label("foo"), Dentry.Prefix.Label("bar"), Dentry.Prefix.Label("baz")), NameTree.Fail)) with self.assertRaises(IllegalArgumentException): NameTreeParsers.parseDentry("/foo/*bar/baz => !") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parseDentry("/&!")
def read(cls, s): """Parse a Dentry from the string `s` with concrete syntax: {{{ dentry ::= prefix '=>' tree }}} where the production `prefix` is from the grammar documented in Prefix.read and the production `tree` is from the grammar documented in dtab.tree.NameTree.read. """ return NameTreeParsers.parseDentry(s)
def test_parseDentry(self): self.assertTrue(NameTreeParsers.parseDentry("/=>!") == Dentry(Path.empty, NameTree.Fail)) self.assertTrue(NameTreeParsers.parseDentry("/ => !") == Dentry(Path.empty, NameTree.Fail)) self.assertTrue(NameTreeParsers.parseDentry("/foo/*/bar => !") == Dentry( Dentry.Prefix( Dentry.Prefix.Label("foo"), Dentry.Prefix.AnyElem, Dentry.Prefix.Label("bar")), NameTree.Fail)) self.assertTrue(NameTreeParsers.parseDentry("/foo/bar/baz => !") == Dentry( Dentry.Prefix( Dentry.Prefix.Label("foo"), Dentry.Prefix.Label("bar"), Dentry.Prefix.Label("baz")), NameTree.Fail)) with self.assertRaises(IllegalArgumentException): NameTreeParsers.parseDentry("/foo/*bar/baz => !") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parseDentry("/&!")