def test_instance_exception(): some_rw = InstanceDouble('tchannel.rw.ReadWriter') c_rw = rw.instance(ClassWithArgs, ('x', some_rw), ('y', rw.number(4))) allow(some_rw).read.and_raise(ReadError("great sadness")) with pytest.raises(ReadError): c_rw.read(bio([1, 2, 3, 4]))
def test_dictionary_read_error(): some_rw = InstanceDouble('tchannel.rw.ReadWriter') allow(some_rw).read.and_raise(ReadError('great sadness')) dict_rw = rw.dictionary(('foo', some_rw)) with pytest.raises(ReadError): dict_rw.read(BytesIO())