From eea1ae5c916ad451bdef7269bd77d3c2224007aa Mon Sep 17 00:00:00 2001 From: Zhuoyun Wei Date: Sun, 9 Jul 2023 02:23:34 -0700 Subject: [PATCH] test: do no load local config when testing --- ash.py | 10 ++++++---- tests/conftest.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ash.py b/ash.py index 7571af9..968b36a 100644 --- a/ash.py +++ b/ash.py @@ -4,6 +4,7 @@ from __future__ import annotations +import os import re import pprint import itertools @@ -27,10 +28,11 @@ class DefaultConfig: app = flask.Flask(__name__, static_url_path='/tweet/static') app.config.from_object(DefaultConfig) -try: - app.config.from_object('config.Config') -except ImportError: - pass +if not os.environ.get('TESTING'): + try: + app.config.from_object('config.Config') + except ImportError: + pass # Set up external Tweets support diff --git a/tests/conftest.py b/tests/conftest.py index 2d32741..4041080 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,11 +7,11 @@ import pytest from elasticsearch import Elasticsearch -from ash import app - @pytest.fixture def client(es_host, es_index): + os.environ['TESTING'] = 'True' + from ash import app app.config.update({ 'TESTING': True, 'T_ES_HOST': es_host,