|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+from os.path import dirname
|
|
1
|
2
|
from django.test import TestCase
|
|
2
|
3
|
from django.core.exceptions import ValidationError
|
|
3
|
4
|
from django.conf import settings
|
|
|
@@ -5,10 +6,12 @@ from django.contrib.flatpages.models import FlatPage
|
|
5
|
6
|
from django.test.utils import override_settings
|
|
6
|
7
|
|
|
7
|
8
|
import oscar
|
|
8
|
|
-from oscar.core.loading import import_module, AppNotFoundError, \
|
|
9
|
|
- get_classes, get_class, ClassNotFoundError
|
|
10
|
|
-from oscar.core.validators import ExtendedURLValidator
|
|
11
|
|
-from oscar.core.validators import URLDoesNotExistValidator
|
|
|
9
|
+from oscar.core.loading import (
|
|
|
10
|
+ import_module, AppNotFoundError, get_classes,
|
|
|
11
|
+ get_class, ClassNotFoundError)
|
|
|
12
|
+from oscar.core.validators import (
|
|
|
13
|
+ ExtendedURLValidator, URLDoesNotExistValidator)
|
|
|
14
|
+from tests import temporary_python_path
|
|
12
|
15
|
|
|
13
|
16
|
|
|
14
|
17
|
class TestImportModule(TestCase):
|
|
|
@@ -78,6 +81,16 @@ class ClassLoadingWithLocalOverrideTests(TestCase):
|
|
78
|
81
|
self.assertEqual('tests._site.shipping.methods', Free.__module__)
|
|
79
|
82
|
self.assertEqual('oscar.apps.shipping.methods', FixedPrice.__module__)
|
|
80
|
83
|
|
|
|
84
|
+ def test_loading_classes_with_root_app(self):
|
|
|
85
|
+ import tests._site.shipping
|
|
|
86
|
+ path = dirname(dirname(tests._site.shipping.__file__))
|
|
|
87
|
+ with temporary_python_path([path]):
|
|
|
88
|
+ self.installed_apps[
|
|
|
89
|
+ self.installed_apps.index('tests._site.shipping')] = 'shipping'
|
|
|
90
|
+ with override_settings(INSTALLED_APPS=self.installed_apps):
|
|
|
91
|
+ (Free,) = get_classes('shipping.methods', ('Free',))
|
|
|
92
|
+ self.assertEqual('shipping.methods', Free.__module__)
|
|
|
93
|
+
|
|
81
|
94
|
|
|
82
|
95
|
class TestExtendedURLValidator(TestCase):
|
|
83
|
96
|
"""
|