Test Overview
This test runs a simple pytest test inside a Docker container. It verifies that the test code executes correctly in the isolated Docker environment and the test passes.
This test runs a simple pytest test inside a Docker container. It verifies that the test code executes correctly in the isolated Docker environment and the test passes.
import pytest def test_addition(): assert 2 + 3 == 5 # Dockerfile content: # FROM python:3.12-slim # WORKDIR /app # COPY test_script.py /app/ # RUN pip install pytest # CMD ["pytest", "test_script.py"]
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Docker daemon starts and builds the image from Dockerfile | Docker image with Python 3.12 and pytest installed is created | - | PASS |
| 2 | Docker container starts from the built image | Container running with working directory /app containing test_script.py | - | PASS |
| 3 | pytest runs test_addition inside the container | pytest executes test and outputs result | assert 2 + 3 == 5 is True | PASS |
| 4 | pytest finishes and container stops | Test passed, container exits cleanly | Test report shows 1 passed, 0 failed | PASS |