'For a given URL, L{http.urlparse} should behave the same as L{urlparse},
except it should always return C{bytes}, never text.'

def test_urlparse(self):

    def urls():
        for scheme in ('http', 'https'):
            for host in ('example.com',):
                for port in (None, 100):
                    for path in ('', 'path'):
                        if (port is not None):
                            host = ((host + ':') + networkString(str(port)))
                            (yield urlunsplit((scheme, host, path, '', '')))
    def assertSameParsing(url, decode):
        '\n                                                Verify    that    C{url}    is    parsed    into    the    same    objects    by    both\n                                                L{http.urlparse}    and    L{urlparse}.\n                                                '
        urlToStandardImplementation = url
        if decode:
            urlToStandardImplementation = url.decode('ascii')
        standardResult = urlparse(urlToStandardImplementation)
        if isinstance(standardResult.scheme, unicode):
            expected = (standardResult.scheme.encode('utf-8'), standardResult.netloc.encode('utf-8'), standardResult.path.encode('utf-8'), standardResult.params.encode('utf-8'), standardResult.query.encode('utf-8'), standardResult.fragment.encode('utf-8'))
        else:
            expected = (standardResult.scheme, standardResult.netloc, standardResult.path, standardResult.params, standardResult.query, standardResult.fragment)
        (scheme, netloc, path, params, query, fragment) = http.urlparse(url)
        self.assertEqual((scheme, netloc, path, params, query, fragment), expected)
        self.assertIsInstance(scheme, bytes)
        self.assertIsInstance(netloc, bytes)
        self.assertIsInstance(path, bytes)
        self.assertIsInstance(params, bytes)
        self.assertIsInstance(query, bytes)
        self.assertIsInstance(fragment, bytes)
    clear_cache()
    for url in urls():
        assertSameParsing(url, True)
        assertSameParsing(url, False)
    clear_cache()
    for url in urls():
        assertSameParsing(url, False)
        assertSameParsing(url, True)
    for url in urls():
        clear_cache()
        assertSameParsing(url, True)
        clear_cache()
        assertSameParsing(url, False)
