1
2
3
4
5
6 from django.test.simple import DjangoTestSuiteRunner
7 from django.conf import settings
8
9 from . import loading
10 from ...exceptions import ResourceNotFound
11
13 """
14 A test suite runner for couchdbkit. This offers the exact same functionality
15 as the default django test suite runner, except that it connects all the couchdbkit
16 django-extended models to a test database. The test database is deleted at the
17 end of the tests. To use this, just add this file to your project and the following
18 line to your settings.py file:
19
20 TEST_RUNNER = 'myproject.testrunner.CouchDbKitTestSuiteRunner'
21 """
22
23 dbs = []
24
26 return "%s_test" % dbname
27
48
50 deleted_databases = []
51 skipcount = 0
52 for app, item in self.dbs:
53 app_label = app.split('.')[-1]
54 db = loading.get_db(app_label)
55 if db.dbname in deleted_databases:
56 skipcount += 1
57 continue
58 try:
59 db.server.delete_db(db.dbname)
60 deleted_databases.append(db.dbname)
61 print "deleted database %s for %s" % (db.dbname, app_label)
62 except ResourceNotFound:
63 print "database %s not found for %s! it was probably already deleted." % (db.dbname, app_label)
64 if skipcount:
65 print "skipped deleting %s app databases that were already deleted" % skipcount
66 return super(CouchDbKitTestSuiteRunner, self).teardown_databases(old_config, **kwargs)
67