1. from django.test import SimpleTestCase, override_settings
    
  2. 
    
  3. 
    
  4. @override_settings(ROOT_URLCONF="view_tests.generic_urls")
    
  5. class URLHandling(SimpleTestCase):
    
  6.     """
    
  7.     Tests for URL handling in views and responses.
    
  8.     """
    
  9. 
    
  10.     redirect_target = "/%E4%B8%AD%E6%96%87/target/"
    
  11. 
    
  12.     def test_nonascii_redirect(self):
    
  13.         """
    
  14.         A non-ASCII argument to HttpRedirect is handled properly.
    
  15.         """
    
  16.         response = self.client.get("/nonascii_redirect/")
    
  17.         self.assertRedirects(response, self.redirect_target)
    
  18. 
    
  19.     def test_permanent_nonascii_redirect(self):
    
  20.         """
    
  21.         A non-ASCII argument to HttpPermanentRedirect is handled properly.
    
  22.         """
    
  23.         response = self.client.get("/permanent_nonascii_redirect/")
    
  24.         self.assertRedirects(response, self.redirect_target, status_code=301)