def test_error_messages(self): e = None try: NameTreeParsers.parsePath("/foo^bar") except IllegalArgumentException as e: pass self.assertTrue("'/foo[^]bar'" in e.message) e = None try: NameTreeParsers.parsePath("/foo/bar/") except IllegalArgumentException as e: pass self.assertTrue("'/foo/bar/[]'" in e.message)
def test_error_messages(self): try: NameTreeParsers.parsePath("/foo^bar") except IllegalArgumentException as e: if PY3: self.assertTrue("'/foo[^]bar'" in str(e)) else: self.assertTrue("'/foo[^]bar'" in e.message) try: NameTreeParsers.parsePath("/foo/bar/") except IllegalArgumentException as e: if PY3: self.assertTrue("'/foo/bar/[]'" in str(e)) else: self.assertTrue("'/foo/bar/[]'" in e.message)
def test_parsePath(self): self.assertTrue(NameTreeParsers.parsePath("/") == Path.empty) self.assertTrue( NameTreeParsers.parsePath("/foo/bar") == Path.Utf8("foo", "bar")) self.assertTrue( NameTreeParsers.parsePath(" /foo/bar ") == Path.Utf8( "foo", "bar")) self.assertTrue( NameTreeParsers.parsePath("/\x66\x6f\x6f") == Path.Utf8("foo")) with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/foo/bar/") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/ foo/bar/ ") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/{}") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/\\?") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/\\x?") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/\\x0?")
def read(cls, s): from dtab.parser import NameTreeParsers return NameTreeParsers.parsePath(s)
def test_parsePath(self): self.assertTrue(NameTreeParsers.parsePath("/") == Path.empty) self.assertTrue(NameTreeParsers.parsePath("/foo/bar") == Path.Utf8("foo", "bar")) self.assertTrue(NameTreeParsers.parsePath(" /foo/bar ") == Path.Utf8("foo", "bar")) self.assertTrue(NameTreeParsers.parsePath("/\x66\x6f\x6f") == Path.Utf8("foo")) with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/foo/bar/") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/ foo/bar/ ") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/{}") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/\\?") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/\\x?") with self.assertRaises(IllegalArgumentException): NameTreeParsers.parsePath("/\\x0?")
def test_show(self): self.assertTrue(NameTreeParsers.parsePath("/foo/bar").show == "/foo/bar")