Пример #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]
Пример #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})
Пример #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])
Пример #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]
Пример #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]
     )
Пример #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]
Пример #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]
     )
Пример #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]
     )
Пример #9
0
 def test_handlesFailures(self):
     assert (
         Failure(ValueError()), 'foo', {}
         == _extractStuffAndWhy({'_why': 'foo',
                                 '_stuff': Failure(ValueError())})
     )
     assert (
         Failure(ValueError()), 'error', {}
         == _extractStuffAndWhy({'_stuff': Failure(ValueError())})
     )
Пример #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]
     )
Пример #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}}
        )
Пример #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())}))
Пример #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())})
     )
Пример #14
0
 def test_handlesMissingFailure(self):
     """
     Missing failures extract a None.
     """
     assert (
         (None, "foo", {}) ==
         _extractStuffAndWhy({"event": "foo"})
     )
Пример #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()
Пример #16
0
 def test_handlesMissingFailure(self):
     assert (
         (None, 'foo', {})
         == _extractStuffAndWhy({'event': 'foo'})
     )