Merge "Speed up SQL unit tests."
This commit is contained in:
commit
9bc14483a4
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ AUTHORS
|
|||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
etc/keystone.conf
|
etc/keystone.conf
|
||||||
|
tests/test.db.pristine
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
from keystone import config
|
from keystone import config
|
||||||
from keystone.common.sql import migration
|
from keystone.common.sql import migration
|
||||||
@ -24,9 +25,13 @@ CONF = config.CONF
|
|||||||
|
|
||||||
|
|
||||||
def setup_test_database():
|
def setup_test_database():
|
||||||
# TODO(termie): be smart about this
|
|
||||||
try:
|
try:
|
||||||
os.unlink('test.db')
|
if os.path.exists('test.db'):
|
||||||
|
os.unlink('test.db')
|
||||||
|
if not os.path.exists('test.db.pristine'):
|
||||||
|
migration.db_sync()
|
||||||
|
shutil.copyfile('test.db', 'test.db.pristine')
|
||||||
|
else:
|
||||||
|
shutil.copyfile('test.db.pristine', 'test.db')
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
migration.db_sync()
|
|
||||||
|
@ -66,6 +66,8 @@ from nose import config
|
|||||||
from nose import core
|
from nose import core
|
||||||
from nose import result
|
from nose import result
|
||||||
|
|
||||||
|
from keystone.common.sql import util
|
||||||
|
|
||||||
|
|
||||||
class _AnsiColorizer(object):
|
class _AnsiColorizer(object):
|
||||||
"""
|
"""
|
||||||
@ -357,4 +359,7 @@ if __name__ == '__main__':
|
|||||||
verbosity=c.verbosity,
|
verbosity=c.verbosity,
|
||||||
config=c,
|
config=c,
|
||||||
show_elapsed=show_elapsed)
|
show_elapsed=show_elapsed)
|
||||||
|
if os.path.exists('tests/test.db.pristine'):
|
||||||
|
os.unlink('tests/test.db.pristine')
|
||||||
|
|
||||||
sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
|
sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
|
||||||
|
Loading…
Reference in New Issue
Block a user