Skip to content

Commit

Permalink
Added info about db before tests are started
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Balcerzak committed Jan 13, 2011
1 parent fa72de5 commit be0577b
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests.py
Expand Up @@ -22,11 +22,31 @@
'guardian',
)

def main():
def run_tests(settings):
from django.test.utils import get_runner
test_runner = get_runner(settings)(interactive=False)

from django.utils.termcolors import colorize
db_conf = settings.DATABASES['default']
output = []
msg = "Starting tests for db backend: %s" % db_conf['ENGINE']
embracer = '=' * len(msg)
output.append(msg)
for key, value in db_conf.iteritems():
line = ' %s: "%s"' % (key, value)
output.append(line)
embracer = colorize('=' * len(max(output, key=lambda s: len(s))),
fg='green', opts=['bold'])
output = [colorize(line, fg='blue') for line in output]
output.insert(0, embracer)
output.append(embracer)
print '\n'.join(output)

TestRunner = get_runner(settings)
test_runner = TestRunner(interactive=False)
failures = test_runner.run_tests(['guardian'])
return failures

def main():
failures = run_tests(settings)
sys.exit(failures)

if __name__ == '__main__':
Expand Down

0 comments on commit be0577b

Please sign in to comment.