From: Christopher Allan Webber Date: Tue, 21 Jun 2011 22:02:49 +0000 (-0500) Subject: Extra checks so that we don't even RUN tests unless the right celery environ set X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=29f1333e722c10d3eff106bd64bb2ded0207e975;p=mediagoblin.git Extra checks so that we don't even RUN tests unless the right celery environ set --- diff --git a/mediagoblin/tests/__init__.py b/mediagoblin/tests/__init__.py index 8aec4a96..adb6a1b3 100644 --- a/mediagoblin/tests/__init__.py +++ b/mediagoblin/tests/__init__.py @@ -16,11 +16,13 @@ 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 diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index b35d54e0..ebb5f1b5 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -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