[Django] #32100: Parameter KEY_PREFIX for DummyCache causing test runner to fail

13 views
Skip to first unread message

Django

unread,
Oct 9, 2020, 12:52:28 PM10/9/20
to django-...@googlegroups.com
#32100: Parameter KEY_PREFIX for DummyCache causing test runner to fail
-----------------------------------------------+------------------------
Reporter: kbhalerao | Owner: nobody
Type: Bug | Status: new
Component: Core (Cache system) | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+------------------------
Summary:
If the KEY_PREFIX option is present while using the DummyCache backend,
the test runner fails with the traceback at the bottom. When running the
server, there via runserver there is no issue.

{{{
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
},
'KEY_PREFIX': "SomeKeyPrefix"
}
}}}

{{{
Traceback (most recent call last):
File "/snap/pycharm-
professional/215/plugins/python/helpers/pycharm/django_test_manage.py",
line 168, in <module>
utility.execute()
File "/snap/pycharm-
professional/215/plugins/python/helpers/pycharm/django_test_manage.py",
line 142, in execute
_create_command().run_from_argv(self.argv)
File "/home/.../lib/python3.8/site-
packages/django/core/management/commands/test.py", line 23, in
run_from_argv
super().run_from_argv(argv)
File "/home/.../DJ3/lib/python3.8/site-
packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/.../lib/python3.8/site-
packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/snap/pycharm-
professional/215/plugins/python/helpers/pycharm/django_test_manage.py",
line 104, in handle
failures = TestRunner(test_labels, **options)
File "/snap/pycharm-
professional/215/plugins/python/helpers/pycharm/django_test_runner.py",
line 254, in run_tests
return DjangoTeamcityTestRunner(**options).run_tests(test_labels,
File "/snap/pycharm-
professional/215/plugins/python/helpers/pycharm/django_test_runner.py",
line 156, in run_tests
return super(DjangoTeamcityTestRunner, self).run_tests(test_labels,
extra_tests, **kwargs)
File "/home/.../lib/python3.8/site-packages/django/test/runner.py", line
684, in run_tests
old_config = self.setup_databases(aliases=databases)
File "/home/.../lib/python3.8/site-packages/django/test/runner.py", line
604, in setup_databases
return _setup_databases(
File "/home/.../lib/python3.8/site-packages/django/test/utils.py", line
169, in setup_databases
connection.creation.create_test_db(
File "/home/.../lib/python3.8/site-
packages/django/db/backends/base/creation.py", line 82, in create_test_db
call_command('createcachetable', database=self.connection.alias)
File "/home/.../lib/python3.8/site-
packages/django/core/management/__init__.py", line 168, in call_command
return command.execute(*args, **defaults)
File "/home/.../lib/python3.8/site-
packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/.../lib/python3.8/site-
packages/django/core/management/commands/createcachetable.py", line 42, in
handle
cache = caches[cache_alias]
File "/home/.../lib/python3.8/site-
packages/django/core/cache/__init__.py", line 79, in __getitem__
cache = _create_cache(alias)
File "/home/.../lib/python3.8/site-
packages/django/core/cache/__init__.py", line 47, in _create_cache
params = {**conf, **kwargs}
TypeError: 'str' object is not a mapping
}}}

Error message is pretty clear, but likely requires a more general solution
implemented in createcachetable.py when DummyCache backend is being used.

Workaround: Do not add options to DummyCache backend, and potentially
update documentation to indicate if options to DummyCache will be a
problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/32100>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 9, 2020, 2:55:17 PM10/9/20
to django-...@googlegroups.com
#32100: Parameter KEY_PREFIX for DummyCache causing test runner to fail
-------------------------------------+-------------------------------------
Reporter: Kaustubh Bhalerao | Owner: nobody
Type: Bug | Status: closed

Component: Core (Cache system) | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => invalid


Comment:

It's a bug in your settings,
[https://docs.djangoproject.com/en/3.1/ref/settings/#key-prefix
KEY_PREFIX] should be in `'default'`:


{{{
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',

'KEY_PREFIX': 'SomeKeyPrefix',
},
}
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32100#comment:1>

Django

unread,
Oct 9, 2020, 3:09:30 PM10/9/20
to django-...@googlegroups.com
#32100: Parameter KEY_PREFIX for DummyCache causing test runner to fail
-------------------------------------+-------------------------------------
Reporter: Kaustubh Bhalerao | Owner: nobody
Type: Bug | Status: closed

Component: Core (Cache system) | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Kaustubh Bhalerao):

My bad!! tests work with the correct format.

--
Ticket URL: <https://code.djangoproject.com/ticket/32100#comment:2>

Reply all
Reply to author
Forward
0 new messages