Example #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)
Example #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)
Example #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)
Example #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?")
Example #5
0
    def read(cls, s):
        from dtab.parser import NameTreeParsers

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