diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-10-14 09:24:24 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-10-14 09:29:30 +0300 |
commit | 8cc1a68d733762ad6baaec439360a84ab8450d3a (patch) | |
tree | 169a30655a64fd2a312734d9aa0d2a7a9d10ef55 /subplot/http.py | |
parent | e34beeecfc807bd3afb9d5b6c2c764fd71027cde (diff) | |
download | ewww-8cc1a68d733762ad6baaec439360a84ab8450d3a.tar.gz |
chore: get global symbols via global()
This lets the module be linted on its own, without the extra-Pythonic
knowledge that they'll be available when this module is embedded into
the test program.
Diffstat (limited to 'subplot/http.py')
-rw-r--r-- | subplot/http.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/subplot/http.py b/subplot/http.py index 5cff887..424b2b1 100644 --- a/subplot/http.py +++ b/subplot/http.py @@ -1,22 +1,13 @@ ############################################################################# # Some helpers to make HTTP requests and examine responses -import json import logging -import os -import random -import re -import shutil -import signal -import subprocess -import time -import urllib.parse - -import yaml # Make an HTTP request. def http_request(ctx, host=None, method=None, url=None): + runcmd = globals()["runcmd"] + exit_code_is = globals()["exit_code_is"] logging.debug(f"Make HTTP request: {method} {url}") runcmd(ctx, ["curl", "-ksv", "-X", method, f"-HHost: {host}", url]) exit_code_is(ctx, 0) @@ -24,6 +15,7 @@ def http_request(ctx, host=None, method=None, url=None): # Check status code of latest HTTP request. def http_status_code_is(ctx, code=None): + assert_eq = globals()["assert_eq"] logging.debug(f"Verifying status code of previous HTTP request is {code}") logging.debug(f" stderr={ctx['stderr']}") pattern = f"\n< HTTP/2 {code} " @@ -32,6 +24,7 @@ def http_status_code_is(ctx, code=None): # Check a HTTP response header for latest request has a given value. def http_header_is(ctx, header=None, value=None): + assert_eq = globals()["assert_eq"] logging.debug(f"Verifying response has header {header}: {value}") s = ctx["stderr"] pattern = f"\n< {header}: {value}" @@ -40,6 +33,7 @@ def http_header_is(ctx, header=None, value=None): # Check a HTTP body response for latest request has a given value. def http_body_is(ctx, body=None): + assert_eq = globals()["assert_eq"] logging.debug(f"Verifying response body is {body!r}") logging.debug(f" actual body={ctx['stdout']!r}") s = ctx["stdout"] |