Commits

Mikhail Korobov committed 7bbb40a

Make running tests easier

  • Participants
  • Parent commits 4b3ea78

Comments (0)

Files changed (5)

File cache_utils/tests.py

     def setUp(self):
         cache._cache.flush_all()
 
-
 class InvalidationTest(ClearMemcachedTest):
 
-    def testInvalidation(self):
+    def test_invalidation(self):
         cache.set('vasia', 'foo', 60, group='names')
         cache.set('petya', 'bar', 60, group='names')
         cache.set('red', 'good', 60, group='colors')
 
 class UtilsTest(ClearMemcachedTest):
 
-    def testSanitizeKeys(self):
+    def test_sanitize_keys(self):
         key = u"12345678901234567890123456789012345678901234567890"
         self.assertTrue(len(key) >= 40)
         key = sanitize_memcached_key(key, 40)
         self.assertTrue(len(key) <= 40)
 
-    def testDecorator(self):
+    def test_decorator(self):
         self._x = 0
 
         @cached(60, group='test-group')

File test_project/__init__.py

Empty file added.

File test_project/manage.py

+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+    import settings # Assumed to be in the same directory.
+except ImportError:
+    import sys
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+if __name__ == "__main__":
+    execute_manager(settings)

File test_project/runtests.py

+#!/usr/bin/env python
+import sys
+from django.core.management import execute_manager
+try:
+    import settings # Assumed to be in the same directory.
+except ImportError:
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+sys.argv.insert(1, 'test')
+
+if len(sys.argv) == 2:
+    sys.argv.append('cache_utils')
+
+if __name__ == "__main__":
+    execute_manager(settings)
+

File test_project/settings.py

+import os
+import sys
+
+PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.dirname(PROJECT_ROOT))
+
+CACHE_BACKEND = 'cache_utils.group_backend://localhost:11211/' #?timeout=60
+
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = ':memory:'
+
+INSTALLED_APPS = (
+    'cache_utils',
+)