def check(_url, _loc, _path, _query, **kwargs):
            obj = Url(**kwargs)
            self.assertEqual(str(obj), _url)
            self.assertEqual(obj.url, _url)
            self.assertEqual(obj.location, _loc)
            self.assertEqual(obj.path, _path)
            self.assertEqual(obj.query, _query)

            obj2 = Url.fromString(_url)
            self.assertEqual(str(obj2), str(obj))
            self.assertEqual(str(obj2), _url)
 def check(url, netloc, host, **kwargs):
     obj = Url.fromString(url)
     self.assertEqual(obj.url, url)
     self.assertEqual(obj.netloc, netloc)
     self.assertEqual(obj.host, host)
     for n, v in kwargs.items():
         self.assertEqual(getattr(obj, n), v)
 def check(url, loc, netloc, host, **kwargs):
     obj = Url(**kwargs)
     self.assertEqual(str(obj), url)
     self.assertEqual(obj.url, url)
     self.assertEqual(obj.netloc, netloc)
     self.assertEqual(obj.host, host)
     self.assertEqual(obj.location, loc)
 def check(url, netloc, host, **kwargs):
     obj = Url.fromString(url)
     self.assertEqual(obj.url, url)
     self.assertEqual(obj.netloc, netloc)
     self.assertEqual(obj.host, host)
     for n, v in kwargs.items():
         self.assertEqual(getattr(obj, n), v)
        def check(_url, _loc, _path, _query, **kwargs):
            obj = Url(**kwargs)
            self.assertEqual(str(obj), _url)
            self.assertEqual(obj.url, _url)
            self.assertEqual(obj.location, _loc)
            self.assertEqual(obj.path, _path)
            self.assertEqual(obj.query, _query)

            obj2 = Url.fromString(_url)
            self.assertEqual(str(obj2), str(obj))
            self.assertEqual(str(obj2), _url)
    def testRelativeFromString(self):

        def check(url, **kwargs):
            obj = Url.fromString(url)
            self.assertEqual(obj.url, url)
            for n, v in kwargs.items():
                self.assertEqual(getattr(obj, n), v)

        self.assertEqual(type(Url.fromString("/")), type(Url()))

        check("/",
              scheme="", hostname="", path="/",
              username=None, password=None, port=None,
              params="", query={}, fragment="",
              location="/")
        check("/sub/file;param?query=string#fragment",
              scheme="", hostname="", path="/sub/file",
              username=None, password=None, port=None,
              params="param", query={"query": ["string"]},
              fragment="fragment",
              location="/sub/file;param?query=string#fragment")
        check("/;param?query=s1&query=s2#fragment",
              scheme="", hostname="", path="/",
              username=None, password=None, port=None,
              params="param", query={"query": ["s1", "s2"]},
              fragment="fragment",
              location="/;param?query=s1&query=s2#fragment")
        check("/sub/file?q1=s1#fragment",
              scheme="", hostname="", path="/sub/file",
              username=None, password=None, port=None,
              params="", query={"q1": ["s1"]},
              fragment="fragment",
              location="/sub/file?q1=s1#fragment")
        check("/sub/file;param#fragment",
              scheme="", hostname="", path="/sub/file",
              username=None, password=None, port=None,
              params="param", query={}, fragment="fragment",
              location="/sub/file;param#fragment")
        check("/sub/file;param?query=string",
              scheme="", hostname="", path="/sub/file",
              username=None, password=None, port=None,
              params="param", query={"query": ["string"]},
              fragment="", location="/sub/file;param?query=string")
 def check(url, loc, **kwargs):
     obj = Url(**kwargs)
     self.assertEqual(str(obj), url)
     self.assertEqual(obj.url, url)
     self.assertEqual(obj.location, loc)
    def testRelativeFromString(self):
        def check(url, **kwargs):
            obj = Url.fromString(url)
            self.assertEqual(obj.url, url)
            for n, v in kwargs.items():
                self.assertEqual(getattr(obj, n), v)

        self.assertEqual(type(Url.fromString("/")), type(Url()))

        check("/",
              scheme="",
              hostname="",
              path="/",
              username=None,
              password=None,
              port=None,
              params="",
              query={},
              fragment="",
              location="/")
        check("/sub/file;param?query=string#fragment",
              scheme="",
              hostname="",
              path="/sub/file",
              username=None,
              password=None,
              port=None,
              params="param",
              query={"query": ["string"]},
              fragment="fragment",
              location="/sub/file;param?query=string#fragment")
        check("/;param?query=s1&query=s2#fragment",
              scheme="",
              hostname="",
              path="/",
              username=None,
              password=None,
              port=None,
              params="param",
              query={"query": ["s1", "s2"]},
              fragment="fragment",
              location="/;param?query=s1&query=s2#fragment")
        check("/sub/file?q1=s1#fragment",
              scheme="",
              hostname="",
              path="/sub/file",
              username=None,
              password=None,
              port=None,
              params="",
              query={"q1": ["s1"]},
              fragment="fragment",
              location="/sub/file?q1=s1#fragment")
        check("/sub/file;param#fragment",
              scheme="",
              hostname="",
              path="/sub/file",
              username=None,
              password=None,
              port=None,
              params="param",
              query={},
              fragment="fragment",
              location="/sub/file;param#fragment")
        check("/sub/file;param?query=string",
              scheme="",
              hostname="",
              path="/sub/file",
              username=None,
              password=None,
              port=None,
              params="param",
              query={"query": ["string"]},
              fragment="",
              location="/sub/file;param?query=string")