diff --git a/tests/__init__.py b/tests/__init__.py index b99a563a..ab756bf7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -38,6 +38,11 @@ class TestBase(unittest.TestCase): init_i18n() +@lru_cache(1) +def running_in_ci(): + return "CI" in os.environ + + def run(cmd, verbosity=0, **kwargs): """Run command without error checking. @return: command return code""" diff --git a/tests/checker/test_httpbin.py b/tests/checker/test_httpbin.py index db17f6c9..6c4d6128 100644 --- a/tests/checker/test_httpbin.py +++ b/tests/checker/test_httpbin.py @@ -16,15 +16,14 @@ """ Test http stuff with httpbin.org. """ -import os import re -from tests import need_network +from tests import need_network, running_in_ci from . import LinkCheckTest def get_httpbin_url(path): """Get httpbin URL.""" - if "CI" in os.environ: + if running_in_ci(): host = "localhost:8080" else: host = "httpbin.org"