|
6 | 6 |
|
7 | 7 |
|
8 | 8 | def pytest_addoption(parser):
|
9 |
| - parser.addoption('--no-pkgroot', action='store_true', default=False, |
10 |
| - help='Remove package root directory from sys.path, ensuring that ' |
11 |
| - 'rest_framework is imported from the installed site-packages. ' |
12 |
| - 'Used for testing the distribution.') |
13 | 9 | parser.addoption('--staticfiles', action='store_true', default=False,
|
14 | 10 | help='Run tests with static files collection, using manifest '
|
15 | 11 | 'staticfiles storage. Used for testing the distribution.')
|
@@ -87,19 +83,15 @@ def pytest_configure(config):
|
87 | 83 | 'guardian',
|
88 | 84 | )
|
89 | 85 |
|
90 |
| - if config.getoption('--no-pkgroot'): |
91 |
| - sys.path.pop(0) |
92 |
| - |
93 |
| - # import rest_framework before pytest re-adds the package root directory. |
94 |
| - import rest_framework |
95 |
| - package_dir = os.path.join(os.getcwd(), 'rest_framework') |
96 |
| - assert not rest_framework.__file__.startswith(package_dir) |
97 |
| - |
98 | 86 | # Manifest storage will raise an exception if static files are not present (ie, a packaging failure).
|
99 | 87 | if config.getoption('--staticfiles'):
|
100 | 88 | import rest_framework
|
101 | 89 | settings.STATIC_ROOT = os.path.join(os.path.dirname(rest_framework.__file__), 'static-root')
|
102 |
| - settings.STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' |
| 90 | + backend = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' |
| 91 | + if django.VERSION < (4, 2): |
| 92 | + settings.STATICFILES_STORAGE = backend |
| 93 | + else: |
| 94 | + settings.STORAGES['staticfiles']['BACKEND'] = backend |
103 | 95 |
|
104 | 96 | django.setup()
|
105 | 97 |
|
|
0 commit comments