Skip to content

Commit

Permalink
Make all fixtures have function scope
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkeller committed Apr 4, 2022
1 parent cc333af commit 102eedb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pytest_docker/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_docker_ip():
return match.group(1)


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def docker_ip():
"""Determine the IP address for TCP connections to Docker containers."""

Expand Down Expand Up @@ -128,15 +128,15 @@ def execute(self, subcommand):
return execute(command)


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def docker_compose_file(pytestconfig):
"""Get an absolute path to the `docker-compose.yml` file. Override this
fixture in your tests if you need a custom location."""

return os.path.join(str(pytestconfig.rootdir), "tests", "docker-compose.yml")


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def docker_compose_project_name():
"""Generate a project name using the current process PID. Override this
fixture in your tests if you need a particular project name."""
Expand All @@ -149,7 +149,7 @@ def get_cleanup_command():
return "down -v"


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def docker_cleanup():
"""Get the docker_compose command to be executed for test clean-up actions.
Override this fixture in your tests if you need to change clean-up actions."""
Expand All @@ -176,7 +176,7 @@ def get_docker_services(
docker_compose.execute(docker_cleanup)


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def docker_services(docker_compose_file, docker_compose_project_name, docker_cleanup):
"""Start all services from a docker compose file (`docker-compose up`).
After test are finished, shutdown all services (`docker-compose down`)."""
Expand Down

0 comments on commit 102eedb

Please sign in to comment.