Extra checks so that we don't even RUN tests unless the right celery environ set
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 21 Jun 2011 22:02:49 +0000 (17:02 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 21 Jun 2011 22:02:49 +0000 (17:02 -0500)
mediagoblin/tests/__init__.py
mediagoblin/tests/tools.py

index 8aec4a96767637d2063b41ec5473398e05da6c3d..adb6a1b3ab041d85751703c0c896211cb14ec2dd 100644 (file)
 
 from mediagoblin import mg_globals
 
-from mediagoblin.tests.tools import MEDIAGOBLIN_TEST_DB_NAME
+from mediagoblin.tests.tools import (
+    MEDIAGOBLIN_TEST_DB_NAME, suicide_if_bad_celery_environ)
 
 
 def setup_package():
-    pass
+    suicide_if_bad_celery_environ()
+
 
 def teardown_package():
     if ((mg_globals.db_connection
index b35d54e00ee4b90cfa915e93fec0c7c974dcfd8f..ebb5f1b564b0b8604e6f3afe051f735f2a1947a9 100644 (file)
@@ -42,17 +42,23 @@ USER_DEV_DIRECTORIES_TO_SETUP = [
     'media/public', 'media/queue',
     'beaker/sessions/data', 'beaker/sessions/lock']
 
+BAD_CELERY_MESSAGE = """\
+Sorry, you *absolutely* must run nosetests with the
+mediagoblin.celery_setup.from_tests module.  Like so:
+$ CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests ./bin/nosetests"""
+
 
 class BadCeleryEnviron(Exception): pass
 
 
-def get_test_app(dump_old_app=True):
+def suicide_if_bad_celery_environ():
     if not os.environ.get('CELERY_CONFIG_MODULE') == \
             'mediagoblin.celery_setup.from_tests':
-        raise BadCeleryEnviron(
-            u"Sorry, you *absolutely* must run nosetests with the\n"
-            u"mediagoblin.celery_setup.from_tests module.  Like so:\n"
-            u"$ CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests ./bin/nosetests")
+        raise BadCeleryEnviron(BAD_CELERY_MESSAGE)
+    
+
+def get_test_app(dump_old_app=True):
+    suicide_if_bad_celery_environ()
 
     global MGOBLIN_APP
     global CELERY_SETUP