def test_upload(client): content = to_bytes('你好吗') files = { 'hello': { 'file': to_text(content), 'filename': 'hello.txt', } } data = { 'abc': 'a', 'a': 'b', } expect_data = {} expect_data.update(data) expect_data.update({k: f['file'] for k, f in files.items()}) response = client.post('/echo', data=data, files=files) assert response.json() == expect_data
def test_to_bytes(bt, expect): assert to_bytes(bt) == expect
def _get_session(client, value): response = client.get('/') assert response.content == to_bytes('hello {}'.format(value))
def test_post(self, client): name = 'Tom' response = client.post(app.url_for('IndexView', name=name)) assert response.data == to_bytes(name + ' post')