Esempio n. 1
0
def test_response_file_body_tell_text():
    from webob.response import ResponseBodyFile

    rbo = ResponseBodyFile(Response())
    assert rbo.tell() == 0
    rbo.write("123456789")
    assert rbo.tell() == 9
Esempio n. 2
0
def test_response_file_body_tell_text():
    from webob.response import ResponseBodyFile

    rbo = ResponseBodyFile(Response())
    assert rbo.tell() == 0
    rbo.write("123456789")
    assert rbo.tell() == 9
Esempio n. 3
0
def test_response_file_body_write_empty_body():
    from webob.response import ResponseBodyFile
    class FakeResponse:
        body = ''
    res = FakeResponse()
    res._app_iter = res.app_iter = None
    rbo = ResponseBodyFile(res)
    rbo.write('baz')
    eq_(res.app_iter, ['baz'])
Esempio n. 4
0
def test_body_file_write_unicode_encodes():
    from webob.response import ResponseBodyFile
    class FakeReponse:
        charset = 'utf-8'
        _app_iter = app_iter = []
    s = unicode('La Pe\xc3\xb1a', 'utf-8')
    res = FakeReponse()
    rbo = ResponseBodyFile(res)
    rbo.write(s)
    eq_(res.app_iter, ['La Pe\xc3\xb1a'])
Esempio n. 5
0
def test_response_file_body_write_empty_body():
    from webob.response import ResponseBodyFile

    class FakeResponse:
        body = ''

    res = FakeResponse()
    res._app_iter = res.app_iter = None
    rbo = ResponseBodyFile(res)
    rbo.write('baz')
    eq_(res.app_iter, ['baz'])
Esempio n. 6
0
def test_body_file_write_unicode_encodes():
    from webob.response import ResponseBodyFile

    class FakeReponse:
        charset = 'utf-8'
        _app_iter = app_iter = []

    s = unicode('La Pe\xc3\xb1a', 'utf-8')
    res = FakeReponse()
    rbo = ResponseBodyFile(res)
    rbo.write(s)
    eq_(res.app_iter, ['La Pe\xc3\xb1a'])