示例#1
0
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
示例#2
0
def test_to_bytes(bt, expect):
    assert to_bytes(bt) == expect
示例#3
0
def _get_session(client, value):
    response = client.get('/')
    assert response.content == to_bytes('hello {}'.format(value))
示例#4
0
def test_to_bytes(bt, expect):
    assert to_bytes(bt) == expect
示例#5
0
 def test_post(self, client):
     name = 'Tom'
     response = client.post(app.url_for('IndexView', name=name))
     assert response.data == to_bytes(name + ' post')