-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Settings' object has no attribute 'SELECT2_THEME' #203
Comments
note: a workaround for users waiting for this to be merged is to import |
Hi @ewjoachim, Thank you for reaching out. I appreciate the effort you put into the bug report. I'd wish everyone would be so meticulous reporting bugs. That being said, I don't think I fully get the use case here: You are trying to override a setting, that isn't set in your project, right? In that case, I feel the error is desirable. Our default values shouldn't have any side effects into your project. I am not a big fan of how Maybe I am missing something important thought. I'd be wonderful if you could further elaborate your use case. Best! |
I think you're missing the point. The problem is not what I override (and it it may convince you, I encourage you to change the override to a setting that's set in the project, such as Select2 itself requires this setting to be set e.g. here, and does not expect this setting to not exist. Either we define |
I've changed details on the reproduction repo. The tests now are: class TestShowcase(TestCase):
@override_settings(USE_I18N=False)
@patch("bugshowcase.select2.get_widget", autospec=True)
def test_1(self, s2):
self.assertEqual(1 + 1, 2)
def test_2(self):
from bugshowcase.select2 import get_widget
widget = get_widget()
self.assertNotEqual(widget.render(name="foo", value="bar"), "") The code under test is:
If you launch test 1 or 2 alone, they work. If you launch the 2 tests in the same process, test 2 fails because And just in case I need to spell it out, no the right fix is not to replace all |
Describe the bug
django-select2 uses django-appconf, which has a problem sometimes appearing when using tests with
@override_settings()
that causes some tests not to be able to see the settings.The fix is outlined here: consists of making sure that in
Select2AppConfig.ready()
, we import the conf module.Exception & Traceback
Code Snippet
https://github.com/ewjoachim/django_select2_showcase_203
To Reproduce
Steps to reproduce the behavior:
pip install -r requirements.txt
python manage.py test bugshowcase/tests
The 1st test is written so that the 1st time django_select2's configuration is loaded is during a
@override_settings
context. Because of this, when the 1st test ends, the settings disappear. The 2nd test shows this by trying to read the settings.The bug is especially annoying as is depends on test order, import order, and many other factors.
Adding an import to
django_select2.conf
within anyAppConfig.ready()
solves it.Expected behavior
no error
The text was updated successfully, but these errors were encountered: