Browse Source

Decode server responses from raw bytes to strings

Uses utf-8, or whatever the server response indicates.
tags/nilmdb-2.0.0
Jim Paris 4 years ago
parent
commit
85d4c419fd
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      tests/test_nilmdb.py

+ 3
- 2
tests/test_nilmdb.py View File

@@ -136,8 +136,9 @@ class TestBlockingServer(object):
thread.join()

def geturl(path):
req = urlopen("http://127.0.0.1:32180" + path, timeout = 10)
return req.read()
resp = urlopen("http://127.0.0.1:32180" + path, timeout = 10)
body = resp.read()
return body.decode(resp.headers.get_content_charset() or 'utf-8')

def getjson(path):
return json.loads(geturl(path))


Loading…
Cancel
Save