Last active
April 18, 2018 09:04
-
-
Save jedie/c119e73d8e7dad48183f9622b430373f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pytest | |
| def set_settings(app_config_class): | |
| """ | |
| Hack: Fill django settings with app-config settings | |
| """ | |
| from django.conf import settings | |
| assert settings.configured | |
| app_config = app_config_class() | |
| app_config_dict = app_config.configure() | |
| prefix = app_config._meta.prefix.upper() | |
| for key, value in app_config_dict.items(): | |
| key = "%s_%s" % (prefix, key) | |
| if hasattr(settings, key): | |
| print("settings.%s already set, skip" % key) | |
| else: | |
| print("settings.%s=%s" % (key, repr(value))) | |
| setattr(settings, key, value) | |
| @pytest.fixture(autouse=True) | |
| def app_config_fix(): | |
| """ | |
| Pytest fixture that will invoked automatically. | |
| work-a-round for: | |
| https://github.com/django-compressor/django-appconf/issues/30 | |
| https://github.com/matthewwithanm/django-imagekit/issues/251 | |
| """ | |
| from imagekit.conf import ImageKitConf | |
| set_settings(ImageKitConf) | |
| from aldryn_search.conf import AldrynSearchAppConf | |
| set_settings(AldrynSearchAppConf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment