diff --git a/README.rst b/README.rst index 76fbc56a87614bb4c3003342d245bd8e1684810b..7997b4deef60ee69afc148c02b5a6d420ccc2bd5 100644 --- a/README.rst +++ b/README.rst @@ -294,6 +294,17 @@ Or, to generate an HTML report:: $ ./bin/coverate html +.. tip:: + + You may significatively speed-up your testing by re-using the same test + database from run to run. In order to do this, just specify the flag + ``--keepdb`` when you run your tests:: + + $ ./bin/django test --settings=beat.web.settings.test -v 2 --keepdb + + In this case, Django will create and keep a test database called + ``test.sql3`` on your current directory. You may delete it when you're done. + .. _snapshot: Local Development Server diff --git a/beat/web/settings/test.py b/beat/web/settings/test.py index 213c5ceaedf3ea2262d5d6b8507dd503c08a79e9..e38b2658456f5f9d01eda579b412dcb422b50bb5 100644 --- a/beat/web/settings/test.py +++ b/beat/web/settings/test.py @@ -36,8 +36,10 @@ ALLOWED_HOSTS = [ 'testserver', ] -# To always use a (in-memory) sqlite3 database for the tests -DATABASES['default'] = { 'ENGINE': 'django.db.backends.sqlite3' } +import sys +if '-k' in sys.argv or '--keepdb' in sys.argv: + # keeps the SQLite3 database around to avoid re-running migrations + DATABASES['default']['TEST'] = {'NAME': 'test.sql3'} PREFIX = os.path.join(os.getcwd(), 'test_prefix') ALGORITHMS_ROOT = os.path.join(PREFIX, 'algorithms')