'Verifies that the list of URLs that come back from a Resolver404
exception contains a list in the right format for printing out in
the DEBUG 404 page with both the patterns and URL names, if available.'

def test_404_tried_urls_have_names(self):

    urls = u'urlpatterns_reverse.named_urls'
    url_types_names = [[{u'type': RegexURLPattern, u'name': u'named-url1'}], [{u'type': RegexURLPattern, u'name': u'named-url2'}], [{u'type': RegexURLPattern, u'name': None}], [{u'type': RegexURLResolver}, {u'type': RegexURLPattern, u'name': u'named-url3'}], [{u'type': RegexURLResolver}, {u'type': RegexURLPattern, u'name': u'named-url4'}], [{u'type': RegexURLResolver}, {u'type': RegexURLPattern, u'name': None}], [{u'type': RegexURLResolver}, {u'type': RegexURLResolver}]]
    try:
        resolve(u'/included/non-existent-url', urlconf=urls)
        self.fail(u'resolve    did    not    raise    a    404')
    except Resolver404 as e:
        self.assertTrue((u'tried' in e.args[0]))
        tried = e.args[0][u'tried']
        self.assertEqual(len(e.args[0][u'tried']), len(url_types_names), (u'Wrong    number    of    tried    URLs    returned.        Expected    %s,    got    %s.' % (len(url_types_names), len(e.args[0][u'tried']))))
        for (tried, expected) in zip(e.args[0][u'tried'], url_types_names):
            for (t, e) in zip(tried, expected):
                (self.assertIsInstance(t, e[u'type']), (str(u'%s    is    not    an    instance    of    %s') % (t, e[u'type'])))
                if (u'name' in e):
                    if (not e[u'name']):
                        self.assertTrue((t.name is None), (u'Expected    no    URL    name    but    found    %s.' % t.name))
                    else:
                        self.assertEqual(t.name, e[u'name'], (u'Wrong    URL    name.        Expected    "%s",    got    "%s".' % (e[u'name'], t.name)))
