Skip to content
This repository
Browse code

Switch to django-nose

  • Loading branch information...
commit 59fce78fd51e57c51221cd175d51f6a2e4779f99 1 parent f6e65fc
David Cramer authored July 30, 2012

Showing 2 changed files with 24 additions and 8 deletions. Show diff stats Hide diff stats

  1. 28  runtests.py
  2. 4  setup.py
28  runtests.py
... ...
@@ -1,8 +1,7 @@
1 1
 #!/usr/bin/env python
2 2
 import sys
3  
-from os.path import dirname, abspath
4  
-
5 3
 from django.conf import settings
  4
+from optparse import OptionParser
6 5
 
7 6
 if not settings.configured:
8 7
     settings.configure(
@@ -23,15 +22,28 @@
23 22
         DEBUG=False,
24 23
     )
25 24
 
26  
-from django.test.simple import run_tests
  25
+from django_nose import NoseTestSuiteRunner
  26
+
  27
+
  28
+def runtests(*test_args, **kwargs):
  29
+    if 'south' in settings.INSTALLED_APPS:
  30
+        from south.management.commands import patch_for_test_db_setup
  31
+        patch_for_test_db_setup()
27 32
 
28  
-def runtests(*test_args):
29 33
     if not test_args:
30 34
         test_args = ['uuidfield']
31  
-    parent = dirname(abspath(__file__))
32  
-    sys.path.insert(0, parent)
33  
-    failures = run_tests(test_args, verbosity=1, interactive='--no-input' not in sys.argv)
  35
+
  36
+    kwargs.setdefault('interactive', False)
  37
+
  38
+    test_runner = NoseTestSuiteRunner(**kwargs)
  39
+
  40
+    failures = test_runner.run_tests(test_args)
34 41
     sys.exit(failures)
35 42
 
36 43
 if __name__ == '__main__':
37  
-    runtests()
  44
+    parser = OptionParser()
  45
+    parser.add_option('--verbosity', dest='verbosity', action='store', default=1, type=int)
  46
+    parser.add_options(NoseTestSuiteRunner.options)
  47
+    (options, args) = parser.parse_args()
  48
+
  49
+    runtests(*args, **options.__dict__)
4  setup.py
@@ -11,6 +11,10 @@
11 11
     install_requires=[
12 12
         'django',
13 13
     ],
  14
+    tests_require=[
  15
+        'psycopg2',
  16
+        'django-nose',
  17
+    ],
14 18
     packages=find_packages(),
15 19
     test_suite='runtests.runtests',
16 20
     include_package_data=True,

0 notes on commit 59fce78

Please sign in to comment.
Something went wrong with that request. Please try again.