Skip to content

Commit

Permalink
Use finally in context manager (#58)
Browse files Browse the repository at this point in the history
* Use `finally` in context manager

* Version 0.10.3

* Update CHANGELOG.md

Co-authored-by: Max <Luminaar@users.noreply.github.com>
  • Loading branch information
hsheth2 and Luminaar committed Jun 14, 2021
1 parent b29309b commit 62c20fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 0.10.3
Changes:
- Ensure that Docker cleanup is executed even with after tests have failed

## Version 0.10.2
Changes:
- Allow higher version of `attrs` (21.0)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pytest-docker
version = 0.10.2
version = 0.10.3
description = Simple pytest fixtures for Docker and docker-compose based tests
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
11 changes: 6 additions & 5 deletions src/pytest_docker/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ def get_docker_services(
# Spawn containers.
docker_compose.execute("up --build -d")

# Let test(s) run.
yield Services(docker_compose)

# Clean up.
docker_compose.execute(docker_cleanup)
try:
# Let test(s) run.
yield Services(docker_compose)
finally:
# Clean up.
docker_compose.execute(docker_cleanup)


@pytest.fixture(scope="session")
Expand Down

0 comments on commit 62c20fe

Please sign in to comment.