in l10n_CM/Unified/conftest.py [0:0]
def serve_live_site(is_live_site, live_site, region, request):
"""Serve the live site only if needed."""
if not is_live_site or is_port_in_use():
return
# only serve content if url is already not served.
try:
ad_html_file, cc_html_file = get_html_files(live_site, region)
http_server = request.getfixturevalue("httpserver")
http_server.expect_request(f"/{live_site}_ad.html").respond_with_data(
ad_html_file, content_type="text/html"
)
http_server.expect_request(f"/{live_site}_cc.html").respond_with_data(
cc_html_file, content_type="text/html"
)
except OSError as e:
if e == errno.EADDRINUSE:
logging.info(f"{live_site} already served.")
finally:
return