def test_only_requires_only_type_or_value(self): SingleException.to_python(dict( type='ValueError', )) SingleException.to_python(dict( value='ValueError', ))
def test_handles_type_in_value(self): result = SingleException.to_python(dict(value="ValueError: unauthorized")) assert result.type == "ValueError" assert result.value == "unauthorized" result = SingleException.to_python(dict(value="ValueError:unauthorized")) assert result.type == "ValueError" assert result.value == "unauthorized"
def test_handles_type_in_value(self): result = SingleException.to_python( dict(value='ValueError: unauthorized', )) assert result.type == 'ValueError' assert result.value == 'unauthorized' result = SingleException.to_python( dict(value='ValueError:unauthorized', )) assert result.type == 'ValueError' assert result.value == 'unauthorized'
def test_handles_type_in_value(self): result = SingleException.to_python(dict( value='ValueError: unauthorized', )) assert result.type == 'ValueError' assert result.value == 'unauthorized' result = SingleException.to_python(dict( value='ValueError:unauthorized', )) assert result.type == 'ValueError' assert result.value == 'unauthorized'
def test_value_serialization_idempotent(self): result = SingleException.to_python({ 'type': None, 'value': {'unauthorized': True}, }).to_json() assert result['type'] is None assert result['value'] == '{"unauthorized":true}' # Don't re-split a json-serialized value on the colon result = SingleException.to_python(result).to_json() assert result['type'] is None assert result['value'] == '{"unauthorized":true}'
def test_value_serialization_idempotent(self): result = SingleException.to_python({ 'type': None, 'value': {'unauthorized': True}, }).to_json() assert 'type' not in result assert result['value'] == '{"unauthorized":true}' # Don't re-split a json-serialized value on the colon result = SingleException.to_python(result).to_json() assert 'type' not in result assert result['value'] == '{"unauthorized":true}'
def test_throws_away_empty_stacktrace(self): result = SingleException.to_python(dict( type='ValueError', value='foo', stacktrace={'frames': []}, )) assert not result.stacktrace
def interface(self): return SingleException.to_python( dict( type='ValueError', value='hello world', module='foo.bar', ))
def test_coerces_object_value_to_string(self): result = SingleException.to_python( dict( type='ValueError', value={'unauthorized': True}, )) assert result.value == '{"unauthorized":true}'
def test_coerces_object_value_to_string(self): result = SingleException.to_python({ 'type': 'ValueError', 'value': { 'unauthorized': True }, }) assert result.value == '{"unauthorized":true}'
def interface(self): return SingleException.to_python( dict( type='ValueError', value='hello world', module='foo.bar', ) )
def interface(self): return SingleException.to_python(dict(type="ValueError", value="hello world", module="foo.bar"))
def test_coerces_object_value_to_string(self): result = SingleException.to_python(dict( type='ValueError', value={'unauthorized': True}, )) assert result.value == '{"unauthorized":true}'
def test_throws_away_empty_stacktrace(self): result = SingleException.to_python(dict(type="ValueError", value="foo", stacktrace={"frames": []})) assert not result.stacktrace
def test_coerces_object_value_to_string(self): result = SingleException.to_python({ 'type': 'ValueError', 'value': {'unauthorized': True}, }) assert result.value == '{"unauthorized":true}'