Skip to content
This repository
Browse code

Cleaning up the test imports to avoid errors when modules are missing

  • Loading branch information...
commit 0c2b55754cd5ffbb5dbf571ea939084945018cb1 1 parent 1e724f8
Charles Leifer authored July 02, 2012

Showing 1 changed file with 18 additions and 5 deletions. Show diff stats Hide diff stats

  1. 23  runtests.py
23  runtests.py
@@ -29,15 +29,28 @@ def get_option_parser():
29 29
     os.environ['PEEWEE_TEST_VERBOSITY'] = str(options.verbosity)
30 30
 
31 31
     import tests
32  
-    from playhouse import tests as extras_tests, tests_apsw, tests_postgres
33 32
 
34  
-    if options.all:
35  
-        modules = [tests, extras_tests, tests_apsw, tests_postgres]
36  
-    elif options.extra:
37  
-        modules = [extras_tests, tests_apsw, tests_postgres]
  33
+    if options.all or options.extra:
  34
+        modules = [tests]
  35
+        from playhouse import tests as extras_tests
  36
+        modules.append(extras_tests)
  37
+        try:
  38
+            from playhouse import tests_apsw
  39
+            modules.append(tests_apsw)
  40
+        except ImportError:
  41
+            print 'Unable to import apsw tests, skipping'
  42
+
  43
+        try:
  44
+            from playhouse import tests_postgres
  45
+            modules.append(tests_postgres)
  46
+        except ImportError:
  47
+            print 'Unable to import postgres_ext tests, skipping'
38 48
     else:
39 49
         modules = [tests]
40 50
 
  51
+    if options.extra:
  52
+        modules.remove(tests)
  53
+
41 54
     results = []
42 55
     any_failures = False
43 56
     any_errors = False

0 notes on commit 0c2b557

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