|
3 | 3 | from __future__ import unicode_literals
|
4 | 4 |
|
5 | 5 | import time
|
| 6 | +import unittest |
6 | 7 |
|
| 8 | +import django |
7 | 9 | from django.core import signals
|
8 | 10 | from django.core.cache import caches
|
9 | 11 | from django.db import close_old_connections
|
@@ -449,24 +451,30 @@ def test_set_fail_on_pickleerror(self):
|
449 | 451 | with self.assertRaises(pickle.PickleError):
|
450 | 452 | self.cache.set('unpicklable', Unpicklable())
|
451 | 453 |
|
| 454 | + @unittest.skipIf(django.VERSION < (1, 11), |
| 455 | + 'get_or_set with `None` not supported (Django ticket #26792)') |
452 | 456 | def test_get_or_set(self):
|
453 | 457 | self.assertIsNone(self.cache.get('projector'))
|
454 | 458 | self.assertEqual(self.cache.get_or_set('projector', 42), 42)
|
455 | 459 | self.assertEqual(self.cache.get('projector'), 42)
|
456 | 460 | self.assertEqual(self.cache.get_or_set('null', None), None)
|
457 | 461 |
|
| 462 | + @unittest.skipIf(django.VERSION < (1, 9), 'get_or_set not supported') |
458 | 463 | def test_get_or_set_callable(self):
|
459 | 464 | def my_callable():
|
460 | 465 | return 'value'
|
461 | 466 |
|
462 | 467 | self.assertEqual(self.cache.get_or_set('mykey', my_callable), 'value')
|
463 | 468 | self.assertEqual(self.cache.get_or_set('mykey', my_callable()), 'value')
|
464 | 469 |
|
| 470 | + @unittest.skipIf(django.VERSION < (1, 9), 'get_or_set not supported') |
465 | 471 | def test_get_or_set_callable_returning_none(self):
|
466 | 472 | self.assertIsNone(self.cache.get_or_set('mykey', lambda: None))
|
467 | 473 | # Previous get_or_set() doesn't store None in the cache.
|
468 | 474 | self.assertEqual(self.cache.get('mykey', 'default'), 'default')
|
469 | 475 |
|
| 476 | + @unittest.skipIf(django.VERSION < (1, 11), |
| 477 | + 'get_or_set with `None` not supported (Django ticket #26792)') |
470 | 478 | def test_get_or_set_version(self):
|
471 | 479 | msg = (
|
472 | 480 | "get_or_set() missing 1 required positional argument: 'default'"
|
@@ -516,6 +524,8 @@ def test_memcached_deletes_key_on_failed_set(self):
|
516 | 524 | value = self.cache.get('small_value')
|
517 | 525 | self.assertTrue(value is None or value == large_value)
|
518 | 526 |
|
| 527 | + # TODO: Fix https://github.com/django-pylibmc/django-pylibmc/issues/6 |
| 528 | + @unittest.expectedFailure |
519 | 529 | def test_close(self):
|
520 | 530 | # For clients that don't manage their connections properly, the
|
521 | 531 | # connection is closed when the request is complete.
|
|
0 commit comments