diff options
author | Anubhav Joshi <anubhav9042@gmail.com> | 2014-04-05 11:34:46 +0530 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-04-06 17:33:43 -0400 |
commit | cd914e31c9a889f18c50c15b4f6ee4959624001f (patch) | |
tree | 291036036473baaf6de621f66a6198ed4bc12451 /tests/test_client_regress | |
parent | d2f4553d705951ca8043d687f9493c559f494a0c (diff) | |
download | django-cd914e31c9a889f18c50c15b4f6ee4959624001f.tar.gz |
Fixed #21977 -- Deprecated SimpleTestCase.urls
Diffstat (limited to 'tests/test_client_regress')
-rw-r--r-- | tests/test_client_regress/tests.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py index d25d36b09f..59cc46b567 100644 --- a/tests/test_client_regress/tests.py +++ b/tests/test_client_regress/tests.py @@ -27,10 +27,10 @@ from .views import CustomTestException @override_settings( - TEMPLATE_DIRS=(os.path.join(os.path.dirname(upath(__file__)), 'templates'),) + TEMPLATE_DIRS=(os.path.join(os.path.dirname(upath(__file__)), 'templates'),), + ROOT_URLCONF='test_client_regress.urls', ) class AssertContainsTests(TestCase): - urls = 'test_client_regress.urls' def test_contains(self): "Responses can be inspected for content, including counting repeated substrings" @@ -191,9 +191,9 @@ class AssertContainsTests(TestCase): self.assertNotContains(response, 'Bye') -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) +@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), + ROOT_URLCONF='test_client_regress.urls',) class AssertTemplateUsedTests(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata.json'] def test_no_context(self): @@ -264,8 +264,8 @@ class AssertTemplateUsedTests(TestCase): self.assertIn("Template 'Valid POST Template' was not a template used to render the response. Actual template(s) used: form_view.html, base.html", str(e)) +@override_settings(ROOT_URLCONF='test_client_regress.urls') class AssertRedirectsTests(TestCase): - urls = 'test_client_regress.urls' def test_redirect_page(self): "An assertion is raised if the original page couldn't be retrieved as expected" @@ -459,8 +459,8 @@ class AssertRedirectsTests(TestCase): self.assertRedirects(response, 'http://testserver/secure_view/', status_code=301) +@override_settings(ROOT_URLCONF='test_client_regress.urls') class AssertFormErrorTests(TestCase): - urls = 'test_client_regress.urls' def test_unknown_form(self): "An assertion is raised if the form name is unknown" @@ -576,8 +576,8 @@ class AssertFormErrorTests(TestCase): self.assertIn("abc: The form 'form' in context 0 does not contain the non-field error 'Some error.' (actual errors: )", str(e)) +@override_settings(ROOT_URLCONF='test_client_regress.urls') class AssertFormsetErrorTests(TestCase): - urls = 'test_client_regress.urls' msg_prefixes = [("", {}), ("abc: ", {"msg_prefix": "abc"})] def setUp(self): @@ -775,9 +775,9 @@ class ProcessedMiddleware(object): request.has_been_processed = True -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) +@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), + ROOT_URLCONF='test_client_regress.urls',) class LoginTests(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata'] def test_login_different_client(self): @@ -817,10 +817,10 @@ class LoginTests(TestCase): @override_settings( PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), - SESSION_ENGINE='test_client_regress.session' + SESSION_ENGINE='test_client_regress.session', + ROOT_URLCONF='test_client_regress.urls', ) class SessionEngineTests(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata'] def test_login(self): @@ -834,8 +834,8 @@ class SessionEngineTests(TestCase): self.assertEqual(response.context['user'].username, 'testclient') +@override_settings(ROOT_URLCONF='test_client_regress.urls',) class URLEscapingTests(TestCase): - urls = 'test_client_regress.urls' def test_simple_argument_get(self): "Get a view that has a simple string argument" @@ -862,9 +862,9 @@ class URLEscapingTests(TestCase): self.assertEqual(response.content, b'Hi, Arthur') -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) +@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), + ROOT_URLCONF='test_client_regress.urls',) class ExceptionTests(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata.json'] def test_exception_cleared(self): @@ -889,8 +889,8 @@ class ExceptionTests(TestCase): self.fail("Staff should be able to visit this page") +@override_settings(ROOT_URLCONF='test_client_regress.urls') class TemplateExceptionTests(TestCase): - urls = 'test_client_regress.urls' def setUp(self): # Reset the loaders so they don't try to render cached templates. @@ -914,8 +914,8 @@ class TemplateExceptionTests(TestCase): # We need two different tests to check URLconf substitution - one to check # it was changed, and another one (without self.urls) to check it was reverted on # teardown. This pair of tests relies upon the alphabetical ordering of test execution. +@override_settings(ROOT_URLCONF='test_client_regress.urls') class UrlconfSubstitutionTests(TestCase): - urls = 'test_client_regress.urls' def test_urlconf_was_changed(self): "TestCase can enforce a custom URLconf on a per-test basis" @@ -936,9 +936,9 @@ class zzUrlconfSubstitutionTests(TestCase): reverse('arg_view', args=['somename']) -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) +@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), + ROOT_URLCONF='test_client_regress.urls',) class ContextTests(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata'] def test_single_context(self): @@ -1007,9 +1007,9 @@ class ContextTests(TestCase): self.assertEqual(response.context['nested'], 'yes') -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) +@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), + ROOT_URLCONF='test_client_regress.urls',) class SessionTests(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata.json'] def test_session(self): @@ -1116,8 +1116,8 @@ class SessionTests(TestCase): self.assertFalse(listener.executed) +@override_settings(ROOT_URLCONF='test_client_regress.urls') class RequestMethodTests(TestCase): - urls = 'test_client_regress.urls' def test_get(self): "Request a view via request method GET" @@ -1164,8 +1164,8 @@ class RequestMethodTests(TestCase): self.assertEqual(response.content, b'request method: PATCH') +@override_settings(ROOT_URLCONF='test_client_regress.urls') class RequestMethodStringDataTests(TestCase): - urls = 'test_client_regress.urls' def test_post(self): "Request a view with string data via request method POST" @@ -1192,8 +1192,8 @@ class RequestMethodStringDataTests(TestCase): self.assertEqual(response.content, b'request method: PATCH') +@override_settings(ROOT_URLCONF='test_client_regress.urls',) class QueryStringTests(TestCase): - urls = 'test_client_regress.urls' def test_get_like_requests(self): # See: https://code.djangoproject.com/ticket/10571. @@ -1247,8 +1247,8 @@ class QueryStringTests(TestCase): self.assertEqual(response.context['request-bar'], 'bang') +@override_settings(ROOT_URLCONF='test_client_regress.urls') class UnicodePayloadTests(TestCase): - urls = 'test_client_regress.urls' def test_simple_unicode_payload(self): "A simple ASCII-only unicode JSON document can be POSTed" @@ -1312,8 +1312,8 @@ class UploadedFileEncodingTest(TestCase): encode_file('IGNORE', 'IGNORE', DummyFile("file.unknown"))[2]) +@override_settings(ROOT_URLCONF='test_client_regress.urls',) class RequestHeadersTest(TestCase): - urls = 'test_client_regress.urls' fixtures = ['testdata'] def test_client_headers(self): @@ -1348,6 +1348,7 @@ class RequestHeadersTest(TestCase): status_code=301, target_status_code=200) +@override_settings(ROOT_URLCONF='test_client_regress.urls') class ReadLimitedStreamTest(TestCase): """ Tests that ensure that HttpRequest.body, HttpRequest.read() and @@ -1355,7 +1356,6 @@ class ReadLimitedStreamTest(TestCase): Refs #14753, #15785 """ - urls = 'test_client_regress.urls' def test_body_from_empty_request(self): """HttpRequest.body on a test client GET request should return @@ -1391,6 +1391,7 @@ class ReadLimitedStreamTest(TestCase): content_type='text/plain').content, payload) +@override_settings(ROOT_URLCONF='test_client_regress.urls') class RequestFactoryStateTest(TestCase): """Regression tests for #15929.""" # These tests are checking that certain middleware don't change certain @@ -1398,7 +1399,6 @@ class RequestFactoryStateTest(TestCase): # ensuring test isolation behavior. So, unusually, it doesn't make sense to # run the tests individually, and if any are failing it is confusing to run # them with any other set of tests. - urls = 'test_client_regress.urls' def common_test_that_should_always_pass(self): request = RequestFactory().get('/') @@ -1418,12 +1418,12 @@ class RequestFactoryStateTest(TestCase): self.common_test_that_should_always_pass() +@override_settings(ROOT_URLCONF='test_client_regress.urls') class RequestFactoryEnvironmentTests(TestCase): """ Regression tests for #8551 and #17067: ensure that environment variables are set correctly in RequestFactory. """ - urls = 'test_client_regress.urls' def test_should_set_correct_env_variables(self): request = RequestFactory().get('/path/') |