Repository navigation
Expand file tree
/
Copy pathtest_web_broken.py
More file actions
73 lines (56 loc) · 1.89 KB
/
Copy pathtest_web_broken.py
File metadata and controls
73 lines (56 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2016 Dean Jackson <deanishe@deanishe.net>
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2016-02-23
#
"""
test_web2.py
"""
from __future__ import print_function, unicode_literals
import os
import pytest
import pytest_httpbin
from workflow import web
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
# Broken. Why doesn't this work with the local httpbin?
def no_test_default_encoding(httpbin):
"""Default encodings for mimetypes."""
url = httpbin.url + '/response-headers'
r = web.get(url)
r.raise_for_status()
# httpbin returns JSON by default. web.py should automatically
# set `encoding` to UTF-8 when mimetype = 'application/json'
assert r.encoding == 'utf-8'
assert isinstance(r.text, unicode)
# Broken. Why doesn't this work with the local httpbin?
def no_test_xml_encoding(httpbin):
"""XML is decoded."""
url = httpbin.url + '/response-headers'
params = {'Content-Type': 'text/xml; charset=UTF-8'}
r = web.get(url, params)
r.raise_for_status()
assert r.encoding == 'utf-8'
assert isinstance(r.text, unicode)
def test_default_encoding_remote(httpbin):
"""Default encodings for mimetypes."""
url = 'http://httpbin.org/response-headers'
r = web.get(url)
r.raise_for_status()
# httpbin returns JSON by default. web.py should automatically
# set `encoding` to UTF-8 when mimetype = 'application/json'
assert r.encoding == 'utf-8'
assert isinstance(r.text, unicode)
def test_xml_encoding_remote(httpbin):
"""XML is decoded."""
url = 'http://httpbin.org/response-headers'
params = {'Content-Type': 'text/xml; charset=UTF-8'}
r = web.get(url, params)
r.raise_for_status()
assert r.encoding == 'utf-8'
assert isinstance(r.text, unicode)
if __name__ == '__main__': # pragma: no cover
pytest.main([__file__])