Mikhail Korobov avatar Mikhail Korobov committed 7bbb40a

Make running tests easier

Comments (0)

Files changed (5)

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')
Add a comment to this file

test_project/__init__.py

Empty file added.

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)

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)
+

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',
+)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.