Skip to content

Commit

Permalink
Merge branch 'release_v0.12.3' into issue_2355_verdi_help_exit_status
Browse files Browse the repository at this point in the history
  • Loading branch information
ltalirz authored Jan 31, 2019
2 parents 9b7654f + d4ddb6b commit 2d3a80a
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions aiida/utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,55 @@ class FixtureManager(object):
@pytest.fixture(scope='session')
def aiida_profile():
with aiida.utils.fixtures.fixture_manager() as fixture_mgr:
fixture_mgr.create_profile()
# set up a test profile for the duration of the tests
from aiida.utils.fixtures import fixture_manager
with fixture_manager():
yield fixture_manager
@pytest.fixture(scope='function')
def test_data(aiida_profile):
# load my test data
yield
fixture_manager.reset_db()
def new_database(aiida_profile):
# clear the database after each test
yield aiida_profile
aiida_profile.reset_db()
def test_my_stuff(test_data):
def test_my_stuff(new_database):
# run a test
@pytest.fixture(scope='function')
def new_database_with_daemon(aiida_profile):
# Configure and start daemon before running JobProcesses
#
# Note: While the global daemon implementation makes this necessary in aiida-core 0.12.x,
# it is no longer necessary for aiida-core 1.0.x with its "runners" (mini-daemons)
import os
from aiida import get_strict_version
from distutils.version import StrictVersion
if get_strict_version() < StrictVersion('1.0.0a1'):
from aiida.backends.utils import set_daemon_user
from aiida.cmdline.commands.daemon import Daemon
from aiida.common import setup
set_daemon_user(aiida_profile.email)
daemon = Daemon()
daemon.logfile = os.path.join(aiida_profile.config_dir,
setup.LOG_SUBDIR, setup.CELERY_LOG_FILE)
daemon.pidfile = os.path.join(aiida_profile.config_dir,
setup.LOG_SUBDIR, setup.CELERY_PID_FILE)
daemon.celerybeat_schedule = os.path.join(aiida_profile.config_dir,
setup.DAEMON_SUBDIR, 'celerybeat-schedule')
if daemon.get_daemon_pid() is None:
daemon.daemon_start()
else:
daemon.daemon_restart()
yield aiida_profile
daemon.kill_daemon()
else:
yield aiida_profile
aiida_profile.reset_db()
"""

Expand Down

0 comments on commit 2d3a80a

Please sign in to comment.