示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
    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?")
示例#5
0
    def read(cls, s):
        from dtab.parser import NameTreeParsers

        return NameTreeParsers.parsePath(s)
示例#6
0
  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?")
示例#7
0
 def test_show(self):
   self.assertTrue(NameTreeParsers.parsePath("/foo/bar").show == "/foo/bar")
示例#8
0
 def read(cls, s):
   from dtab.parser import NameTreeParsers
   return NameTreeParsers.parsePath(s)