def test_failsOnConflictingEventAnd_why(self): """ Raise ValueError if both _why and event are in the event_dict. """ with pytest.raises(ValueError) as e: _extractStuffAndWhy({"_why": "foo", "event": "bar"}) assert "Both `_why` and `event` supplied." == e.value.args[0]
def test_handlesFailures(self): """ Extracts failures and events. """ f = Failure(ValueError()) assert (f, "foo", {}) == _extractStuffAndWhy({"_why": "foo", "_stuff": f}) assert (f, None, {}) == _extractStuffAndWhy({"_stuff": f})
def test_failsOnConflictingEventAnd_why(self): """ Raise ValueError if both _why and event are in the event_dict. """ with pytest.raises(ValueError) as e: _extractStuffAndWhy({'_why': 'foo', 'event': 'bar'}) assert ("Both `_why` and `event` supplied." == e.value.args[0])
def test_extractFailsOnTwoFailures(self): """ Raise ValueError if both _stuff and event contain exceptions. """ with pytest.raises(ValueError) as e: _extractStuffAndWhy({"_stuff": Failure(ValueError()), "event": Failure(TypeError())}) assert "Both _stuff and event contain an Exception/Failure." == e.value.args[0]
def test_failsOnConflictingEventAnd_why(self): with pytest.raises(ValueError) as e: _extractStuffAndWhy({'_why': 'foo', 'event': 'bar'}) assert ( 'Both `_why` and `event` supplied.' == e.value.args[0] )
def test_extractFailsOnTwoFailures(self): with pytest.raises(ValueError) as e: _extractStuffAndWhy({'_stuff': Failure(ValueError()), 'event': Failure(TypeError())}) assert ( 'Both _stuff and event contain an Exception/Failure.' == e.value.args[0] )
def test_failsOnConflictingEventAnd_why(self): """ Raise ValueError if both _why and event are in the event_dict. """ with pytest.raises(ValueError) as e: _extractStuffAndWhy({'_why': 'foo', 'event': 'bar'}) assert ( "Both `_why` and `event` supplied." == e.value.args[0] )
def test_handlesFailures(self): assert ( Failure(ValueError()), 'foo', {} == _extractStuffAndWhy({'_why': 'foo', '_stuff': Failure(ValueError())}) ) assert ( Failure(ValueError()), 'error', {} == _extractStuffAndWhy({'_stuff': Failure(ValueError())}) )
def test_extractFailsOnTwoFailures(self): """ Raise ValueError if both _stuff and event contain exceptions. """ with pytest.raises(ValueError) as e: _extractStuffAndWhy({'_stuff': Failure(ValueError()), 'event': Failure(TypeError())}) assert ( "Both _stuff and event contain an Exception/Failure." == e.value.args[0] )
def test_handlesFailures(self): """ Extracts failures and events. """ f = Failure(ValueError()) assert ({"value": f}, "foo", {}) == _extractStuffAndWhy( {"_why": "foo", "_stuff": {"value": f}} ) assert ({"value": f}, None, {}) == _extractStuffAndWhy( {"_stuff": {"value": f}} )
def test_handlesFailures(self): """ Extracts failures and events. """ assert (Failure(ValueError()), "foo", {} == _extractStuffAndWhy({ "_why": "foo", "_stuff": Failure(ValueError()) })) assert (Failure(ValueError()), "error", {} == _extractStuffAndWhy({"_stuff": Failure(ValueError())}))
def test_handlesFailures(self): """ Extracts failures and events. """ assert ( Failure(ValueError()), "foo", {} == _extractStuffAndWhy({"_why": "foo", "_stuff": Failure(ValueError())}) ) assert ( Failure(ValueError()), "error", {} == _extractStuffAndWhy({"_stuff": Failure(ValueError())}) )
def test_handlesMissingFailure(self): """ Missing failures extract a None. """ assert ( (None, "foo", {}) == _extractStuffAndWhy({"event": "foo"}) )
def test_recognizesErrorsAndCleansThem(self): """ If no error is supplied, the environment is checked for one. If one is found, it's used and cleared afterwards so log.err doesn't add it as well. """ try: raise ValueError except ValueError: f = Failure() _stuff, _why, ed = _extractStuffAndWhy({'event': 'foo'}) assert _stuff.value is f.value with pytest.raises(NoCurrentExceptionError): Failure()
def test_handlesMissingFailure(self): assert ( (None, 'foo', {}) == _extractStuffAndWhy({'event': 'foo'}) )