<commit_before># -*- coding: utf-8 -*-
import unittest

from tests.utils import has_no_django
from thumbnails.cache_backends import DjangoCacheBackend, SimpleCacheBackend
from thumbnails.images import Thumbnail


class CacheBackendTestMixin(object):

    def setUp(self):
        self.backend = self.BACKEND()

    def test_get_empty(self):
        self.assertIsNone(self.backend.get('not-in-cache'))

    def test_set_and_get(self):
        thumbnail = Thumbnail(['n', 'ame'])
        self.backend.set(thumbnail)
        cached_thumbnail = self.backend.get(thumbnail.name)
        print(cached_thumbnail)
        self.assertIsInstance(cached_thumbnail, Thumbnail)
        self.assertEqual(cached_thumbnail.name, thumbnail.name)


class SimpleCacheBackendTestCase(CacheBackendTestMixin, unittest.TestCase):
    BACKEND = SimpleCacheBackend


@unittest.skipIf(has_no_django(), 'Django is not installed')
class DjangoCacheBackendTestCase(CacheBackendTestMixin, unittest.TestCase):
    BACKEND = DjangoCacheBackend<commit_msg>Remove print statement<commit_after># -*- coding: utf-8 -*-
import unittest

from tests.utils import has_no_django
from thumbnails.cache_backends import DjangoCacheBackend, SimpleCacheBackend
from thumbnails.images import Thumbnail


class CacheBackendTestMixin(object):

    def setUp(self):
        self.backend = self.BACKEND()

    def test_get_empty(self):
        self.assertIsNone(self.backend.get('not-in-cache'))

    def test_set_and_get(self):
        thumbnail = Thumbnail(['n', 'ame'])
        self.backend.set(thumbnail)
        cached_thumbnail = self.backend.get(thumbnail.name)
        self.assertIsInstance(cached_thumbnail, Thumbnail)
        self.assertEqual(cached_thumbnail.name, thumbnail.name)


class SimpleCacheBackendTestCase(CacheBackendTestMixin, unittest.TestCase):
    BACKEND = SimpleCacheBackend


@unittest.skipIf(has_no_django(), 'Django is not installed')
class DjangoCacheBackendTestCase(CacheBackendTestMixin, unittest.TestCase):
    BACKEND = DjangoCacheBackend
{'fraction_non_alphanumeric': 0.0949085516559565, 'fraction_numerical': 0.0009886307464162135, 'mean_word_length': 4.653631284916201, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7364263', 'n_tokens_mistral': 610, 'n_tokens_neox': 605, 'n_words': 110}