Beispiel #1
0
def test_pickle_serializer_with_error(join):
    join.side_effect = RuntimeError('ooops')
    stdin = pickle.dumps([{}] + exec_path_join_mod)
    stdout = do_serve(stdin, 'pickle')
    stdout_obj = pickle.loads(stdout)
    assert stdout_obj[0] == {}
    exc = stdout_obj[1]['exception']
    assert isinstance(exc, RuntimeError)
    assert exc.args == ('ooops', )
Beispiel #2
0
def test_json_serializer_with_error(join):
    err = RuntimeError('ooops')
    join.side_effect = err
    stdin = json.dumps([{}] + exec_path_join_mod)
    stdout = do_serve(stdin, 'json')
    stdout_obj = json.loads(stdout)
    assert stdout_obj[0] == {}
    exc = stdout_obj[1]['exception']
    assert exc == {
        'class': err.__class__.__module__ + '.' + err.__class__.__name__,
        'args': ['ooops',]
    }
Beispiel #3
0
def test_json_serializer():
    stdin = json.dumps([{}] + exec_path_join_mod)
    stdout = do_serve(stdin, 'json')
    stdout_obj = json.loads(stdout)
    assert stdout_obj[0] == {}
    assert stdout_obj[1] == {'return': '/foo/bar/baz'}
Beispiel #4
0
def test_pickle_serializer():
    stdin = pickle.dumps([{}] + exec_path_join_mod)
    stdout = do_serve(stdin, 'pickle')
    stdout_obj = pickle.loads(stdout)
    assert stdout_obj[0] == {}
    assert stdout_obj[1] == {'return': '/foo/bar/baz'}
Beispiel #5
0
def test_do_serve_dies():
    with pytest.raises(ValueError):
        do_serve('{', 'json')