conftest.py

  • Fixtures will be visible to all test modules
  • We can put to subdirectories
  • In should not be imported as import conftest, it is the local plugin
import pytest
import tasks
from tasks import Task

@pytest.fixture()
def tasks_db(tmpdir):
    """Connect to db before tests, disconnect after."""
    # Setup : start db
		tasks.start_tasks_db(str(tmpdir), 'tiny') 
		yield # this is where the testing happens
    # Teardown : stop db
    tasks.stop_tasks_db()
SuperMade with Super