|
|
@@ -1,15 +1,14 @@
|
|
1
|
1
|
from django.test import TestCase
|
|
2
|
2
|
from django.core.exceptions import ValidationError
|
|
3
|
3
|
from django.conf import settings
|
|
4
|
|
-
|
|
5
|
4
|
from django.contrib.flatpages.models import FlatPage
|
|
|
5
|
+from django.test.utils import override_settings
|
|
6
|
6
|
|
|
7
|
7
|
import oscar
|
|
8
|
8
|
from oscar.core.loading import import_module, AppNotFoundError, \
|
|
9
|
9
|
get_classes, get_class, ClassNotFoundError
|
|
10
|
10
|
from oscar.core.validators import ExtendedURLValidator
|
|
11
|
11
|
from oscar.core.validators import URLDoesNotExistValidator
|
|
12
|
|
-from oscar.test import patch_settings
|
|
13
|
12
|
|
|
14
|
13
|
|
|
15
|
14
|
class TestImportModule(TestCase):
|
|
|
@@ -59,22 +58,22 @@ class ClassLoadingWithLocalOverrideTests(TestCase):
|
|
59
|
58
|
self.installed_apps[self.installed_apps.index('oscar.apps.shipping')] = 'tests.site.shipping'
|
|
60
|
59
|
|
|
61
|
60
|
def test_loading_class_defined_in_local_module(self):
|
|
62
|
|
- with patch_settings(INSTALLED_APPS=self.installed_apps):
|
|
|
61
|
+ with override_settings(INSTALLED_APPS=self.installed_apps):
|
|
63
|
62
|
(Free,) = get_classes('shipping.methods', ('Free',))
|
|
64
|
63
|
self.assertEqual('tests.site.shipping.methods', Free.__module__)
|
|
65
|
64
|
|
|
66
|
65
|
def test_loading_class_which_is_not_defined_in_local_module(self):
|
|
67
|
|
- with patch_settings(INSTALLED_APPS=self.installed_apps):
|
|
|
66
|
+ with override_settings(INSTALLED_APPS=self.installed_apps):
|
|
68
|
67
|
(FixedPrice,) = get_classes('shipping.methods', ('FixedPrice',))
|
|
69
|
68
|
self.assertEqual('oscar.apps.shipping.methods', FixedPrice.__module__)
|
|
70
|
69
|
|
|
71
|
70
|
def test_loading_class_from_module_not_defined_in_local_app(self):
|
|
72
|
|
- with patch_settings(INSTALLED_APPS=self.installed_apps):
|
|
|
71
|
+ with override_settings(INSTALLED_APPS=self.installed_apps):
|
|
73
|
72
|
(Repository,) = get_classes('shipping.repository', ('Repository',))
|
|
74
|
73
|
self.assertEqual('oscar.apps.shipping.repository', Repository.__module__)
|
|
75
|
74
|
|
|
76
|
75
|
def test_loading_classes_defined_in_both_local_and_oscar_modules(self):
|
|
77
|
|
- with patch_settings(INSTALLED_APPS=self.installed_apps):
|
|
|
76
|
+ with override_settings(INSTALLED_APPS=self.installed_apps):
|
|
78
|
77
|
(Free, FixedPrice) = get_classes('shipping.methods', ('Free', 'FixedPrice'))
|
|
79
|
78
|
self.assertEqual('tests.site.shipping.methods', Free.__module__)
|
|
80
|
79
|
self.assertEqual('oscar.apps.shipping.methods', FixedPrice.__module__)
|
|
|
@@ -142,7 +141,7 @@ class ClassLoadingWithLocalOverrideWithMultipleSegmentsTests(TestCase):
|
|
142
|
141
|
self.installed_apps[self.installed_apps.index('oscar.apps.shipping')] = 'tests.site.apps.shipping'
|
|
143
|
142
|
|
|
144
|
143
|
def test_loading_class_defined_in_local_module(self):
|
|
145
|
|
- with patch_settings(INSTALLED_APPS=self.installed_apps):
|
|
|
144
|
+ with override_settings(INSTALLED_APPS=self.installed_apps):
|
|
146
|
145
|
(Free,) = get_classes('shipping.methods', ('Free',))
|
|
147
|
146
|
self.assertEqual('tests.site.apps.shipping.methods', Free.__module__)
|
|
148
|
147
|
|