CAPTCHA_TEST_MODE doesn't work with override_settings decorator
See original GitHub issueDjango provides some decorators to modify settings on a per-test or per-test-class basis: django.test.override_settings
and django.test.modify_settings
(https://docs.djangoproject.com/en/dev/topics/testing/tools/#overriding-settings).
However, it seems django-simple-captcha reads and stores the project’s value of settings.CAPTCHA_TEST_MODE
(and other settings) only the first time captcha.conf.settings
is imported. Consequently, one must either specify CAPTCHA_TEST_MODE globally for all tests in a custom settings.py, or monkey-patch captcha.conf.settings
…
It would make testing easier if settings were always read on-the-fly, rather than cached.
Or, failing that, it would be good to at least provide notice in the config documentation (particularly for CAPTCHA_TEST_MODE) that they cannot be overridden by override_settings
and modify_settings
.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:10
- Comments:6 (1 by maintainers)
Top GitHub Comments
FTR neither does this work:
This is the only way how I managed to get it working:
There is a solution for this. To make the CAPTCHA_TEST_MODE work, it needs to be set to True and the form will only be valid if you set captcha_0 and captcha_1. captcha_0 needs a hash (I copied one from my browser) and captcha_1 needs to contain “PASSED” (can be lower or uppercase) in string format.
for example: “captcha_0”: “8e10ebf60c5f23fd6e6a9959853730cd69062a15”, “captcha_1”: “PASSED”,