|
4 | 4 | from django.db import connection
|
5 | 5 | from pytest_django.asserts import assertNumQueries
|
6 | 6 |
|
7 |
| -from django.conf import settings |
8 | 7 | from django.core.exceptions import ImproperlyConfigured
|
9 | 8 | from django.test import Client
|
10 | 9 | from django.test.utils import TZ_SUPPORT
|
@@ -50,12 +49,16 @@ def setup(self):
|
50 | 49 | )
|
51 | 50 |
|
52 | 51 |
|
| 52 | +@pytest.fixture(autouse=True) |
| 53 | +def url_setting_set(settings): |
| 54 | + old_root_urlconf = settings.ROOT_URLCONF |
| 55 | + settings.ROOT_URLCONF = "test_generic_views.urls" |
| 56 | + yield settings |
| 57 | + settings.ROOT_URLCONF = old_root_urlconf |
| 58 | + |
| 59 | + |
53 | 60 | @pytest.mark.django_db
|
54 | 61 | class TestArchiveIndexView(TestDataMixin):
|
55 |
| - @pytest.fixture(autouse=True) |
56 |
| - def url_setting_set(self): |
57 |
| - settings.ROOT_URLCONF = "test_generic_views.urls" |
58 |
| - |
59 | 62 | def test_archive_view(self):
|
60 | 63 | res = client.get("/dates/books/")
|
61 | 64 | assert res.status_code == 200
|
@@ -216,10 +219,6 @@ def test_archive_view_without_date_field(self):
|
216 | 219 |
|
217 | 220 | @pytest.mark.django_db
|
218 | 221 | class TestYearArchiveView(TestDataMixin):
|
219 |
| - @pytest.fixture(autouse=True) |
220 |
| - def url_setting_set(self): |
221 |
| - settings.ROOT_URLCONF = "test_generic_views.urls" |
222 |
| - |
223 | 222 | def test_year_view(self):
|
224 | 223 | res = client.get("/dates/books/2008/")
|
225 | 224 | assert res.status_code == 200
|
@@ -389,10 +388,6 @@ def test_get_dated_items_not_implemented(self):
|
389 | 388 |
|
390 | 389 | @pytest.mark.django_db
|
391 | 390 | class TestMonthArchiveView(TestDataMixin):
|
392 |
| - @pytest.fixture(autouse=True) |
393 |
| - def url_setting_set(self): |
394 |
| - settings.ROOT_URLCONF = "test_generic_views.urls" |
395 |
| - |
396 | 391 | def test_month_view(self):
|
397 | 392 | res = client.get("/dates/books/2008/oct/")
|
398 | 393 | assert res.status_code == 200
|
@@ -552,10 +547,6 @@ def test_date_list_order(self):
|
552 | 547 |
|
553 | 548 | @pytest.mark.django_db
|
554 | 549 | class TestWeekArchiveView(TestDataMixin):
|
555 |
| - @pytest.fixture(autouse=True) |
556 |
| - def url_setting_set(self): |
557 |
| - settings.ROOT_URLCONF = "test_generic_views.urls" |
558 |
| - |
559 | 550 | def test_week_view(self):
|
560 | 551 | res = client.get("/dates/books/2008/week/39/")
|
561 | 552 | assert res.status_code == 200
|
@@ -692,10 +683,6 @@ def test_aware_datetime_week_view(self, settings):
|
692 | 683 |
|
693 | 684 | @pytest.mark.django_db
|
694 | 685 | class TestDayArchiveView(TestDataMixin):
|
695 |
| - @pytest.fixture(autouse=True) |
696 |
| - def url_setting_set(self): |
697 |
| - settings.ROOT_URLCONF = "test_generic_views.urls" |
698 |
| - |
699 | 686 | def test_day_view(self):
|
700 | 687 | res = client.get("/dates/books/2008/oct/01/")
|
701 | 688 | assert res.status_code == 200
|
@@ -837,10 +824,6 @@ def test_aware_datetime_day_view(self, settings):
|
837 | 824 |
|
838 | 825 | @pytest.mark.django_db
|
839 | 826 | class TestDateDetailView(TestDataMixin):
|
840 |
| - @pytest.fixture(autouse=True) |
841 |
| - def url_setting_set(self): |
842 |
| - settings.ROOT_URLCONF = "test_generic_views.urls" |
843 |
| - |
844 | 827 | def test_date_detail_by_pk(self):
|
845 | 828 | res = client.get("/dates/books/2008/oct/01/%s/" % self.book1.pk)
|
846 | 829 | assert res.status_code == 200
|
|
0 commit comments