Merge "Use isolated filebased sqlite for each test process"
This commit is contained in:
commit
97d5afc42d
@ -1,5 +1,5 @@
|
||||
[DEFAULT]
|
||||
test_command=SOLAR_DB=${SOLAR_DB:=sqlite://} \
|
||||
py.test ./solar --subunit $LISTOPT $IDOPTION
|
||||
test_command=SOLAR_DB=${SOLAR_DB:='sqlite:////tmp/solar_{PID}.db'} \
|
||||
py.test --clean ./solar --subunit $LISTOPT $IDOPTION
|
||||
test_id_option=--subunit-load-list=$IDFILE
|
||||
test_list_option=--collectonly
|
||||
|
@ -4,5 +4,3 @@ except ImportError:
|
||||
pass
|
||||
else:
|
||||
monkey.patch_all()
|
||||
from solar.dblayer.gevent_patches import patch_all
|
||||
patch_all()
|
||||
|
34
solar/conftest.py
Normal file
34
solar/conftest.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from solar.config import C
|
||||
from solar import utils
|
||||
|
||||
|
||||
C.solar_db = C.solar_db.format(PID=os.getpid())
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--clean", action="store_true", default=False,
|
||||
help="Use this option for additional cleanup")
|
||||
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
if config.getoption("clean"):
|
||||
db, opts = utils.parse_database_conn(C.solar_db)
|
||||
if db.mode == 'sqlite' and os.path.isfile(db.database):
|
||||
os.unlink(db.database)
|
@ -1,3 +1,11 @@
|
||||
try:
|
||||
from gevent import monkey
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
from solar.dblayer.gevent_patches import patch_all
|
||||
patch_all()
|
||||
|
||||
from solar.dblayer.model import ModelMeta
|
||||
from solar.config import C
|
||||
from solar.utils import parse_database_conn
|
||||
|
Loading…
Reference in New Issue
Block a user