def test_http():

    from .exception import BadJson

    b2_http = B2Http()

    # Error from B2
    print('TEST: error object from B2')
    try:
        b2_http.post_json_return_json('https://api.backblaze.com/b2api/v1/b2_get_file_info', {}, {})
        assert False, 'should have failed with bad json'
    except BadJson as e:
        assert str(e) == 'Bad request: required field fileId is missing'

    # Successful get
    print('TEST: get')
    with b2_http.get_content('https://api.backblaze.com/test/echo_zeros?length=10', {}) as response:
        assert response.status_code == 200
        response_data = six.b('').join(response.iter_content())
        assert response_data == six.b(chr(0) * 10)

    # Successful post
    print('TEST: post')
    response_dict = b2_http.post_json_return_json(
        'https://api.backblaze.com/api/build_version', {}, {}
    )
    assert 'timestamp' in response_dict

    # Unknown host
    print('TEST: unknown host')
    try:
        b2_http.post_json_return_json('https://unknown.backblaze.com', {}, {})
        assert False, 'should have failed with unknown host'
    except UnknownHost as e:
        pass

    # Broken pipe
    print('TEST: broken pipe')
    try:
        data = six.BytesIO(six.b(chr(0)) * 10000000)
        b2_http.post_content_return_json('https://api.backblaze.com/bad_url', {}, data)
        assert False, 'should have failed with broken pipe'
    except BrokenPipe as e:
        pass

    # Generic connection error
    print('TEST: generic connection error')
    try:
        with b2_http.get_content('https://www.backblaze.com:80/bad_url', {}) as response:
            assert False, 'should have failed with connection error'
            response.iter_content()  # make pyflakes happy
    except ConnectionError as e:
        pass
This command tells the current context to reset itself, losing what has been done so far. If a escape context has been
dataset/ETHPy150Open Backblaze/B2_Command_Line_Tool/b2/b2http.py/test_http--crossover with--dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.5/extras/completion/py/pymel/core/context.py/ctxAbort