Explicitly set encoding for http requests in tests

Due to the upgrade to charset-normalizer 2.0.4 guessing the encoding
inside the tests did not work anymore and caused the umlaut tests to
fail. Explicitly specifying the encoding on the requests' response
object fixes this.
This commit is contained in:
Sebastian Lohff 2021-09-07 23:12:01 +02:00
rodič d87a42cf8e
revize 41a0f64ff7
1 změnil soubory, kde provedl 4 přidání a 1 odebrání

Zobrazit soubor

@ -92,11 +92,14 @@ def datadir(tmp_path):
def make_request(path='/', host='localhost', port=SERVEFILE_DEFAULT_PORT, method='get', protocol='http', timeout=5,
**kwargs):
encoding='utf-8', **kwargs):
url = '{}://{}:{}{}'.format(protocol, host, port, path)
print('Calling {} on {} with {}'.format(method, url, kwargs))
r = getattr(requests, method)(url, **kwargs)
if r.encoding is None and encoding:
r.encoding = encoding
return r