Allow overriding Eve settings from env in test

Environment variables for Eve settings are now used in unit tests.
This commit is contained in:
Francesco Siddi 2016-04-26 12:33:20 +02:00
parent 974f135e63
commit aa47c2b4a6
2 changed files with 16 additions and 1 deletions

View File

@ -4,12 +4,17 @@ import json
import copy import copy
import sys import sys
import logging import logging
import datetime import datetime
import os import os
import base64 import base64
from bson import ObjectId, tz_util from bson import ObjectId, tz_util
# Override Eve settings before importing eve.tests.
import common_test_settings
common_test_settings.override_eve()
from eve.tests import TestMinimal from eve.tests import TestMinimal
import pymongo.collection import pymongo.collection
from flask.testing import FlaskClient from flask.testing import FlaskClient

View File

@ -1,3 +1,13 @@
from settings import * from settings import *
from eve.tests.test_settings import MONGO_DBNAME from eve.tests.test_settings import MONGO_DBNAME
def override_eve():
from eve.tests import test_settings
from eve import tests
test_settings.MONGO_HOST = MONGO_HOST
test_settings.MONGO_PORT = MONGO_PORT
tests.MONGO_HOST = MONGO_HOST
tests.MONGO_PORT = MONGO_PORT