Пример #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')