From 46d4433a1d56e92aeb07637fb5c2a6d1b2850a3f Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Tue, 7 Sep 2021 23:12:01 +0200 Subject: [PATCH] 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. --- tests/test_servefile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_servefile.py b/tests/test_servefile.py index cf76cf6..cf40243 100644 --- a/tests/test_servefile.py +++ b/tests/test_servefile.py @@ -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