Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def test_status_code(http_service):
assert response.status_code == status
```
> The default `docker_setup` command includes `--wait`, which respects either the
> image `HEALTHCHECK` or the compose `healthcheck`. Generally, if those
> are configured properly, `wait_until_responsive` should not be required.

By default, this plugin will try to open `docker-compose.yml` in your
`tests` directory. If you need to use a custom location, override the
`docker_compose_file` fixture inside your `conftest.py` file:
Expand Down Expand Up @@ -138,7 +142,7 @@ def docker_compose_project_name() -> str:
# Stop the stack before starting a new one
@pytest.fixture(scope="session")
def docker_setup():
return ["down -v", "up --build -d"]
return ["down -v", "up --build --wait"]
```


Expand Down
2 changes: 1 addition & 1 deletion src/pytest_docker/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def docker_cleanup() -> Union[List[str], str]:


def get_setup_command() -> Union[List[str], str]:
return ["up --build -d"]
return ["up --build --wait"]


@pytest.fixture(scope=containers_scope)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_docker_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_docker_services() -> None:
# Both should have been called.
assert check_output.call_args_list == [
mock.call(
'docker compose -f "docker-compose.yml" -p "pytest123" up --build -d',
'docker compose -f "docker-compose.yml" -p "pytest123" up --build --wait',
stderr=subprocess.STDOUT,
shell=True,
),
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_docker_services_unused_port() -> None:
assert check_output.call_args_list == [
mock.call(
'docker compose -f "docker-compose.yml" -p "pytest123" '
"up --build -d", # pylint: disable:=implicit-str-concat
'up --build --wait', # pylint: disable:=implicit-str-concat
shell=True,
stderr=subprocess.STDOUT,
),
Expand Down Expand Up @@ -147,7 +147,7 @@ def test_docker_services_failure() -> None:
assert check_output.call_args_list == [
mock.call(
'docker compose -f "docker-compose.yml" -p "pytest123" '
"up --build -d", # pylint: disable:=implicit-str-concat
"up --build --wait", # pylint: disable:=implicit-str-concat
shell=True,
stderr=subprocess.STDOUT,
)
Expand Down Expand Up @@ -188,7 +188,7 @@ def test_single_commands() -> None:
"docker compose",
"docker-compose.yml",
docker_compose_project_name="pytest123",
docker_setup="up --build -d",
docker_setup="up --build --wait",
docker_cleanup="down -v",
) as services:
assert isinstance(services, Services)
Expand All @@ -212,7 +212,7 @@ def test_single_commands() -> None:
# Both should have been called.
assert check_output.call_args_list == [
mock.call(
'docker compose -f "docker-compose.yml" -p "pytest123" up --build -d',
'docker compose -f "docker-compose.yml" -p "pytest123" up --build --wait',
stderr=subprocess.STDOUT,
shell=True,
),
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_multiple_commands() -> None:
"docker compose",
"docker-compose.yml",
docker_compose_project_name="pytest123",
docker_setup=["ps", "up --build -d"],
docker_setup=["ps", "up --build --wait"],
docker_cleanup=["down -v", "ps"],
) as services:
assert isinstance(services, Services)
Expand Down Expand Up @@ -271,7 +271,7 @@ def test_multiple_commands() -> None:
shell=True,
),
mock.call(
'docker compose -f "docker-compose.yml" -p "pytest123" up --build -d',
'docker compose -f "docker-compose.yml" -p "pytest123" up --build --wait',
stderr=subprocess.STDOUT,
shell=True,
),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_docker_cleanup(docker_cleanup: List[str]) -> None:


def test_docker_setup(docker_setup: List[str]) -> None:
assert docker_setup == ["up --build -d"]
assert docker_setup == ["up --build --wait"]


def test_docker_compose_comand(docker_compose_command: str) -> None:
Expand Down