From 1cb7f3d78a0c3dcad06afab691e3685e030df79d Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Mon, 5 Jun 2023 19:30:59 +0100 Subject: [PATCH] Test on GitHub with httpbin from a container Avoid failures due to the web service. --- .github/workflows/build.yml | 6 ++++++ tests/checker/test_httpbin.py | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bfc8740..c7d84b1f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,12 @@ jobs: - python-version: "3.8" toxenv: minreqs + services: + httpbin: + image: kennethreitz/httpbin + ports: + - 8080:80 + steps: - name: Install OS dependencies run: | diff --git a/tests/checker/test_httpbin.py b/tests/checker/test_httpbin.py index e24f4a7e..db17f6c9 100644 --- a/tests/checker/test_httpbin.py +++ b/tests/checker/test_httpbin.py @@ -16,15 +16,19 @@ """ Test http stuff with httpbin.org. """ +import os import re from tests import need_network from . import LinkCheckTest def get_httpbin_url(path): - """Get httpbin URL. Note that this also could be a local - httpbin installation, but right now this uses the official site.""" - return "http://httpbin.org%s" % path + """Get httpbin URL.""" + if "CI" in os.environ: + host = "localhost:8080" + else: + host = "httpbin.org" + return f"http://{host}{path}" class TestHttpbin(LinkCheckTest):