Opened 7 years ago

Closed 4 years ago

#10853 closed Bug (fixed)

Django unit test fails when using the dummy cache backend.

Reported by: Stavros Korokithakis Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using the dummy cache backend, the test that tests the cache fails (understandably), but it's annoying to have a test fail when this is the indended behaviour. Shouldn't this check for the dummy backend and not run the test (or expect the test to fail) if so?

======================================================================
FAIL: Doctest: django.contrib.sessions.tests
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for django.contrib.sessions.tests
  File "/Library/Python/2.5/site-packages/django/contrib/sessions/tests.py", line 0, in tests

----------------------------------------------------------------------
File "/Library/Python/2.5/site-packages/django/contrib/sessions/tests.py", line 140, in django.contrib.sessions.tests
Failed example:
    cache_session.exists(cache_session.session_key)
Expected:
    True
Got:
    False

Attachments (1)

10853-1.diff (1.4 KB) - added by Claude Paroz 5 years ago.
Set explicit cache for CacheSessionTests

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by Salkot

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Ran into this too. A solution might involve http://code.djangoproject.com/ticket/4788.

comment:2 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:3 Changed 6 years ago by b14ck

Has patch: set
Patch needs improvement: set
Version: 1.0SVN

Hey guys, I took a crack at fixing this, you can see the patch / pull request here: https://github.com/django/django/pull/5

Obviously, my patch is suboptimal, maybe someone could take a look at it and make it more elegant?

I'd love to see this bug get squashed though, it is really annoying when running in development mode.

comment:4 Changed 5 years ago by Chris Beaven

Severity: Normal
Type: Bug

Changed 5 years ago by Claude Paroz

Attachment: 10853-1.diff added

Set explicit cache for CacheSessionTests

comment:5 Changed 5 years ago by Claude Paroz

Easy pickings: unset
Patch needs improvement: unset
UI/UX: unset

Attached patch try to explicitely set the cache to LocMem instead of skipping the test when the dummy backend is setup.

comment:6 Changed 5 years ago by anonymous

Same problem for me. It's very annoying.

comment:7 Changed 4 years ago by Ivan Virabyan

Can someone apply the patch to trunk?

comment:8 Changed 4 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In 486e67598f8d8e83890ef3c90399d660d8e9eee6:

Fixed #10853 -- Skipped some sessions tests with dummy cache backend

Note: See TracTickets for help on using tickets.
Back to Top