Conftest

To provide the Fixture in all the directory.

You can have a conftest.py for each repository that provide the fixtures for that directory. pytest will automatically scan for that file to read the fixture.

For example, consider the example ibn Fixture. If we create a new file in the same folder called conftest.py with the following conrtents:

import pytest
from src.services.MyService import MyService
from src.services.Database import Database

@pytest.fixture
def database():
    return Database()

@pytest.fixture
def app(database):
    return MyService(database)

And then our test file can just be like

class TestMyService:
    def test_load_user_should_success(self, app):
        actual = app.load_user("Austin")
        assert actual is True

    def test_load_user_should_success_2(self, app):
        actual = app.load_user("Austin")
        assert actual is True