              # ... and for legacy purposes:
              self.assertEqual(match[0], func)
              self.assertEqual(match[1], args)
              self.assertEqual(match[2], kwargs)
 
</s> remove             # Bail early for non-ASCII strings (they can't be functions).
            lookup_view = lookup_view.encode('ascii')
            mod_name, func_name = get_mod_func(lookup_view)
 </s> add  </s> remove from django.core.exceptions import ImproperlyConfigured
 </s> add from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist </s> remove                     raise AttributeError("'%s.%s' is not a callable." % (mod_name, func_name))
        except (ImportError, AttributeError):
 </s> add                     raise ViewDoesNotExist(
                        "Could not import %s.%s. View is not callable."
                    % (mod_name, func_name))
        except AttributeError:
            if not can_fail:
                raise ViewDoesNotExist(
                    "Could not import %s. View does not exist in module %s."
                    % (lookup_view, mod_name))
        except ImportError:
            ownermod, submod = get_mod_func(mod_name)
            if (not can_fail and submod != '' and
                    not module_has_submodule(import_module(ownermod), submod)):
                raise ViewDoesNotExist(
                    "Could not import %s. Owning module %s does not exist."
                    % (lookup_view, mod_name)) </s> remove         try:
            return get_callable(callback), {}
        except (ImportError, AttributeError), e:
            raise ViewDoesNotExist("Tried %s. Error was: %s" % (callback, str(e)))
 </s> add         return get_callable(callback), {}
class ErroneousViewTests(TestCase):
    urls = 'regressiontests.urlpatterns_reverse.erroneous_urls'

    def test_erroneous_resolve(self):
        self.assertRaises(ImportError, self.client.get, '/erroneous_inner/')
        self.assertRaises(ImportError, self.client.get, '/erroneous_outer/')
        self.assertRaises(ViewDoesNotExist, self.client.get, '/missing_inner/')
        self.assertRaises(ViewDoesNotExist, self.client.get, '/missing_outer/')
        self.assertRaises(ViewDoesNotExist, self.client.get, '/uncallable/')

              # ... and for legacy purposes:
              self.assertEqual(match[0], func)
              self.assertEqual(match[1], args)
              self.assertEqual(match[2], kwargs)
class ErroneousViewTests(TestCase):
    urls = 'regressiontests.urlpatterns_reverse.erroneous_urls'

    def test_erroneous_resolve(self):
        self.assertRaises(ImportError, self.client.get, '/erroneous_inner/')
        self.assertRaises(ImportError, self.client.get, '/erroneous_outer/')
        self.assertRaises(ViewDoesNotExist, self.client.get, '/missing_inner/')
        self.assertRaises(ViewDoesNotExist, self.client.get, '/missing_outer/')
        self.assertRaises(ViewDoesNotExist, self.client.get, '/uncallable/')

keep keep keep add
 Fixed #10802 -- Handle ImportErrors and AttributeErrors gracefully when raised by the URL resolver system during startup. Many thanks, IonelMaries and Bas Peschier.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16420 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
tests/regressiontests/urlpatterns_reverse/tests.py