From 95093da80bba95551da0e1f9fd2492786ccd42d4 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Jan 15 2018 16:30:04 +0000 Subject: Introduce conftest module Move the fixtures to conftest module. pytest discover these fixture and make them available for all tests modules. Signed-off-by: Nir Soffer --- diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..8055c88 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,21 @@ +""" +Fixtures for sanlock testing. +""" + +import pytest + +from . import util + + +@pytest.fixture +def sanlock_daemon(): + """ + Run sanlock daemon during a test. + """ + p = util.start_daemon() + try: + util.wait_for_daemon(0.5) + yield + finally: + p.terminate() + p.wait() diff --git a/tests/daemon_test.py b/tests/daemon_test.py index d84b838..1e94563 100644 --- a/tests/daemon_test.py +++ b/tests/daemon_test.py @@ -12,20 +12,6 @@ import pytest from . import util -@pytest.fixture -def sanlock_daemon(): - """ - Run sanlock daemon during a test. - """ - p = util.start_daemon() - try: - util.wait_for_daemon(0.5) - yield - finally: - p.terminate() - p.wait() - - def test_single_instance(sanlock_daemon): # Starting another instance while the daemon must fail. p = util.start_daemon()