浏览代码

Refs #26666 -- Fixed test failures caused by assertRedirects changes (#6701)

Tobias McNulty 8 年之前
父节点
当前提交
78a0ca67f6
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      django/test/testcases.py

+ 4 - 1
django/test/testcases.py

@@ -303,7 +303,10 @@ class SimpleTestCase(unittest.TestCase):
                 path = urljoin(response.request['PATH_INFO'], path)
 
             if fetch_redirect_response:
-                if netloc:
+                # netloc might be empty, or in cases where Django tests the
+                # HTTP scheme, the convention is for netloc to be 'testserver'.
+                # Trust both as "internal" URLs here.
+                if netloc and netloc != 'testserver':
                     raise ValueError(
                         "The Django test client is unable to fetch remote URLs (got %s). "
                         "Use assertRedirects(..., fetch_redirect_response=False) instead." % url