From 9c7b7ba070d93ac9c0854c89f1216cb4720d6025 Mon Sep 17 00:00:00 2001 From: Username Date: Sun, 22 Feb 2026 15:38:00 +0100 Subject: [PATCH] add compose-based test runner for Python 2.7 Dockerfile.test builds production image with pytest baked in. compose.test.yml mounts source as volume for fast iteration. Usage: podman-compose -f compose.test.yml run --rm test --- Dockerfile.test | 29 +++++++++++++++++++++++++++++ compose.test.yml | 18 ++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Dockerfile.test create mode 100644 compose.test.yml diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..22a00cc --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,29 @@ +FROM python:2.7-slim + +WORKDIR /app + +RUN sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list && \ + sed -i 's/security.debian.org/archive.debian.org/g' /etc/apt/sources.list && \ + sed -i '/buster-updates/d' /etc/apt/sources.list && \ + echo 'deb http://archive.debian.org/debian-security buster/updates main' >> /etc/apt/sources.list && \ + apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y --no-install-recommends gcc libc-dev && \ + rm -rf /var/lib/apt/lists/* + +RUN pip install --upgrade "pip<21" "setuptools<45" "wheel<0.38" + +COPY requirements.txt . +RUN pip install -r requirements.txt || true +RUN pip install pytest + +RUN mkdir -p /app/data && \ + python -c "import pyasn" 2>/dev/null && \ + pyasn_util_download.py --latest && \ + pyasn_util_convert.py --single rib.*.bz2 /app/data/ipasn.dat && \ + rm -f rib.*.bz2 || \ + echo "pyasn database setup skipped" + +RUN apt-get purge -y gcc libc-dev && apt-get autoremove -y || true + +CMD ["python", "-m", "pytest", "tests/", "-v", "--tb=short"] diff --git a/compose.test.yml b/compose.test.yml new file mode 100644 index 0000000..80bc89f --- /dev/null +++ b/compose.test.yml @@ -0,0 +1,18 @@ +# PPF test runner (Python 2.7, production deps + pytest) +# +# Mounts source and tests as volumes so no rebuild needed between runs. +# +# Usage: +# podman-compose -f compose.test.yml run --rm test +# podman-compose -f compose.test.yml run --rm test python -m pytest tests/test_fetch.py -v + +services: + test: + container_name: ppf-test + build: + context: . + dockerfile: Dockerfile.test + volumes: + - .:/app:ro,Z + working_dir: /app + command: python -m pytest tests/ -v --tb=short