remove unused imports of get_main_database
[mygpo.git] / mygpo / test.py
blob6159be7f6c1cbeeea0a5d3c17cdc562bd45401c7
1 from couchdbkit.ext.django.testrunner import CouchDbKitTestSuiteRunner
3 from django.conf import settings
6 # inspired by
7 # http://djangosnippets.org/snippets/2211/
9 class MygpoTestSuiteRunner(CouchDbKitTestSuiteRunner):
10 """
11 Test runner that is able to skip some tests according to settings.py
12 """
14 def __init__(self, *args, **kwargs):
15 self.EXCLUDED_APPS = getattr(settings, 'TEST_EXCLUDE', [])
16 settings.TESTING = True
17 super(MygpoTestSuiteRunner, self).__init__(*args, **kwargs)
20 def build_suite(self, *args, **kwargs):
21 suite = super(MygpoTestSuiteRunner, self).build_suite(*args, **kwargs)
22 if not args[0] and not getattr(settings, 'RUN_ALL_TESTS', False):
23 tests = []
24 for case in suite:
25 pkg = case.__class__.__module__.split('.')[0]
26 if pkg not in self.EXCLUDED_APPS:
27 tests.append(case)
28 suite._tests = tests
29 return suite
32 def create_auth_string(username, password):
33 import base64
34 credentials = base64.encodestring("%s:%s" % (username, password)).rstrip()
35 auth_string = 'Basic %s' % credentials
36 return auth_string