Browse files

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

  • Loading branch information...
1 parent 1e724f8 commit 0c2b55754cd5ffbb5dbf571ea939084945018cb1 @coleifer committed Jul 2, 2012
Showing with 18 additions and 5 deletions.
  1. +18 −5 runtests.py
View
23 runtests.py
@@ -29,15 +29,28 @@ def get_option_parser():
os.environ['PEEWEE_TEST_VERBOSITY'] = str(options.verbosity)
import tests
- from playhouse import tests as extras_tests, tests_apsw, tests_postgres
- if options.all:
- modules = [tests, extras_tests, tests_apsw, tests_postgres]
- elif options.extra:
- modules = [extras_tests, tests_apsw, tests_postgres]
+ if options.all or options.extra:
+ modules = [tests]
+ from playhouse import tests as extras_tests
+ modules.append(extras_tests)
+ try:
+ from playhouse import tests_apsw
+ modules.append(tests_apsw)
+ except ImportError:
+ print 'Unable to import apsw tests, skipping'
+
+ try:
+ from playhouse import tests_postgres
+ modules.append(tests_postgres)
+ except ImportError:
+ print 'Unable to import postgres_ext tests, skipping'
else:
modules = [tests]
+ if options.extra:
+ modules.remove(tests)
+
results = []
any_failures = False
any_errors = False

0 comments on commit 0c2b557

Please sign in to comment.