Browse Source

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.
Sebastian Lohff 1 month ago
parent
commit
41a0f64ff7
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      tests/test_servefile.py

+ 4
- 1
tests/test_servefile.py View File

@@ -92,11 +92,14 @@ def datadir(tmp_path):
92 92
 
93 93
 
94 94
 def make_request(path='/', host='localhost', port=SERVEFILE_DEFAULT_PORT, method='get', protocol='http', timeout=5,
95
-                 **kwargs):
95
+                 encoding='utf-8', **kwargs):
96 96
     url = '{}://{}:{}{}'.format(protocol, host, port, path)
97 97
     print('Calling {} on {} with {}'.format(method, url, kwargs))
98 98
     r = getattr(requests, method)(url, **kwargs)
99 99
 
100
+    if r.encoding is None and encoding:
101
+        r.encoding = encoding
102
+
100 103
     return r
101 104
 
102 105
 

Loading…
Cancel
Save