Example #1
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]
Example #2
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})
Example #3
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])
Example #4
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]
Example #5
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]
     )
Example #6
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]
Example #7
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]
     )
Example #8
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]
     )
Example #9
0
 def test_handlesFailures(self):
     assert (
         Failure(ValueError()), 'foo', {}
         == _extractStuffAndWhy({'_why': 'foo',
                                 '_stuff': Failure(ValueError())})
     )
     assert (
         Failure(ValueError()), 'error', {}
         == _extractStuffAndWhy({'_stuff': Failure(ValueError())})
     )
Example #10
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]
     )
Example #11
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}}
        )
Example #12
0
 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())}))
Example #13
0
 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())})
     )
Example #14
0
 def test_handlesMissingFailure(self):
     """
     Missing failures extract a None.
     """
     assert (
         (None, "foo", {}) ==
         _extractStuffAndWhy({"event": "foo"})
     )
Example #15
0
 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()
Example #16
0
 def test_handlesMissingFailure(self):
     assert (
         (None, 'foo', {})
         == _extractStuffAndWhy({'event': 'foo'})
     )