Exemplo n.º 1
0
 def test_oopsMessage(self):
     """oopsMessage pushes and pops the messages."""
     utility = ErrorReportingUtility()
     del utility._oops_config.publishers[:]
     with utility.oopsMessage({'a': 'b', 'c': 'd'}):
         self.assertEqual(
             {0: {'a': 'b', 'c': 'd'}}, utility._oops_messages)
         # An additional message doesn't supplant the original message.
         with utility.oopsMessage(dict(e='f', a='z', c='d')):
             self.assertEqual({
                 0: {'a': 'b', 'c': 'd'},
                 1: {'a': 'z', 'e': 'f', 'c': 'd'},
                 }, utility._oops_messages)
         # Messages are removed when out of context.
         self.assertEqual(
             {0: {'a': 'b', 'c': 'd'}},
             utility._oops_messages)
Exemplo n.º 2
0
 def test__makeErrorReport_includes_oops_messages(self):
     """The error report should include the oops messages."""
     utility = ErrorReportingUtility()
     utility._oops_config.publisher = None
     with utility.oopsMessage(dict(a='b', c='d')):
         try:
             raise ArbitraryException('foo')
         except ArbitraryException:
             info = sys.exc_info()
             oops = utility._oops_config.create(dict(exc_info=info))
             self.assertEqual({'<oops-message-0>': "{'a': 'b', 'c': 'd'}"},
                              oops['req_vars'])
Exemplo n.º 3
0
 def test_oopsMessage(self):
     """oopsMessage pushes and pops the messages."""
     utility = ErrorReportingUtility()
     utility._oops_config.publisher = None
     with utility.oopsMessage({'a': 'b', 'c': 'd'}):
         self.assertEqual({0: {'a': 'b', 'c': 'd'}}, utility._oops_messages)
         # An additional message doesn't supplant the original message.
         with utility.oopsMessage(dict(e='f', a='z', c='d')):
             self.assertEqual(
                 {
                     0: {
                         'a': 'b',
                         'c': 'd'
                     },
                     1: {
                         'a': 'z',
                         'e': 'f',
                         'c': 'd'
                     },
                 }, utility._oops_messages)
         # Messages are removed when out of context.
         self.assertEqual({0: {'a': 'b', 'c': 'd'}}, utility._oops_messages)
Exemplo n.º 4
0
 def test__makeErrorReport_includes_oops_messages(self):
     """The error report should include the oops messages."""
     utility = ErrorReportingUtility()
     del utility._oops_config.publishers[:]
     with utility.oopsMessage(dict(a='b', c='d')):
         try:
             raise ArbitraryException('foo')
         except ArbitraryException:
             info = sys.exc_info()
             oops = utility._oops_config.create(dict(exc_info=info))
             self.assertEqual(
                 {'<oops-message-0>': "{'a': 'b', 'c': 'd'}"},
                 oops['req_vars'])
Exemplo n.º 5
0
 def test__makeErrorReport_combines_request_and_error_vars(self):
     """The oops messages should be distinct from real request vars."""
     utility = ErrorReportingUtility()
     del utility._oops_config.publishers[:]
     request = ScriptRequest([('c', 'd')])
     with utility.oopsMessage(dict(a='b')):
         try:
             raise ArbitraryException('foo')
         except ArbitraryException:
             info = sys.exc_info()
             oops = utility._oops_config.create(
                     dict(exc_info=info, http_request=request))
             self.assertEqual(
                 {'<oops-message-0>': "{'a': 'b'}", 'c': 'd'},
                 oops['req_vars'])
Exemplo n.º 6
0
 def test__makeErrorReport_combines_request_and_error_vars(self):
     """The oops messages should be distinct from real request vars."""
     utility = ErrorReportingUtility()
     utility._oops_config.publisher = None
     request = ScriptRequest([('c', 'd')])
     with utility.oopsMessage(dict(a='b')):
         try:
             raise ArbitraryException('foo')
         except ArbitraryException:
             info = sys.exc_info()
             oops = utility._oops_config.create(
                 dict(exc_info=info, http_request=request))
             self.assertEqual({
                 '<oops-message-0>': "{'a': 'b'}",
                 'c': 'd'
             }, oops['req_vars'])