From a3be3b44b80d1258deaf97fbbeede77fe126f817 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Feb 28 2018 14:48:35 +0000 Subject: Allow tests to run in virtualenv If celery is installed in virtualenv, the executable will not be in /usr/bin. We also need make sure to preserve env from parent process and only add the new values (so that PATH adjusted by virtualenv still remains). Merges https://pagure.io/pagure/pull-request/3005 --- diff --git a/tests/__init__.py b/tests/__init__.py index 0d2c83f..16fdeae 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -369,12 +369,13 @@ class Modeltests(SimplePagureTest): # Using cocurrency 2 to test with some concurrency, but not be heavy # Using eventlet so that worker.terminate kills everything self.workerlog = open(os.path.join('.', 'worker.log'), 'w') - celery_exec = '/usr/bin/celery' - celery_env = { + celery_exec = 'celery' + celery_env = os.environ.copy() + celery_env.update({ 'PAGURE_BROKER_URL': celery_broker_url, 'PAGURE_CONFIG': os.path.join(self.path, 'config'), 'PYTHONPATH': '.' - } + }) celery_cwd = os.path.normpath( os.path.join(os.path.dirname(__file__), '..')