Ejemplo n.º 1
0
 def test_get_frame_data_supplement_empty(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(supplement={}), MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url=None, line=None, column=None, expression=None,
              warnings=[], extra=None),
         supplement)
Ejemplo n.º 2
0
 def test_get_frame_data_broken_warnings(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(
                 supplement=dict(
                     warnings=object()
                 )),
             MY_LINE_NUMBER))
     self.assertEqual([], supplement['warnings'])
Ejemplo n.º 3
0
 def test_get_frame_data_standard(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(get_frame(), MY_LINE_NUMBER))
     self.assertEqual(MY_FILE_NAME, filename)
     self.assertEqual(MY_LINE_NUMBER, lineno)
     self.assertEqual('get_frame', name)
     self.assertStartsWith(line, 'MY_LINE_NUMBER = ')
     self.assertEqual(__name__, modname)
     self.assertIs(None, supplement)
     self.assertIs(None, info)
Ejemplo n.º 4
0
 def test_get_frame_data_standard(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(get_frame(), MY_LINE_NUMBER))
     self.assertEqual(MY_FILE_NAME, filename)
     self.assertEqual(MY_LINE_NUMBER, lineno)
     self.assertEqual('get_frame', name)
     self.assertStartsWith(line, 'MY_LINE_NUMBER = ')
     self.assertEqual(__name__, modname)
     self.assertIs(None, supplement)
     self.assertIs(None, info)
Ejemplo n.º 5
0
 def test_get_frame_data_supplement_bad_getInfo(self):
     def boo_hiss():
         raise ValueError()
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(supplement=dict(getInfo=boo_hiss)),
             MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url=None, line=None, column=None, expression=None,
              warnings=[], extra=None),
         supplement)
Ejemplo n.º 6
0
 def test_get_frame_data_supplement_empty(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(get_frame(supplement={}),
                                    MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url=None,
              line=None,
              column=None,
              expression=None,
              warnings=[],
              extra=None), supplement)
Ejemplo n.º 7
0
    def test_get_frame_data_supplement_bad_getInfo(self):
        def boo_hiss():
            raise ValueError()

        filename, lineno, name, line, modname, supplement, info = (
            stacktrace._get_frame_data(
                get_frame(supplement=dict(getInfo=boo_hiss)), MY_LINE_NUMBER))
        self.assertEqual(
            dict(source_url=None,
                 line=None,
                 column=None,
                 expression=None,
                 warnings=[],
                 extra=None), supplement)
Ejemplo n.º 8
0
 def test_get_frame_data_supplement_all(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(
                 supplement=dict(source_url='/foo/bar.pt',
                                 line=42,
                                 column=84,
                                 expression='tal:define="foo view/foo"',
                                 warnings=('watch out', 'pass auf'),
                                 getInfo=lambda: 'read all about it')),
             MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url='/foo/bar.pt',
              line='42',
              column='84',
              expression='tal:define="foo view/foo"',
              warnings=['watch out', 'pass auf'],
              extra='read all about it'), supplement)
Ejemplo n.º 9
0
 def test_get_frame_data_supplement_all(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(
                 supplement=dict(
                     source_url='/foo/bar.pt',
                     line=42,
                     column=84,
                     expression='tal:define="foo view/foo"',
                     warnings=('watch out', 'pass auf'),
                     getInfo=lambda: 'read all about it'
                 )),
             MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url='/foo/bar.pt', line='42', column='84',
              expression='tal:define="foo view/foo"',
              warnings=['watch out', 'pass auf'],
              extra='read all about it'),
         supplement)
Ejemplo n.º 10
0
 def test_get_frame_data_broken_str(self):
     bad = BadString()
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(supplement=dict(source_url=bad,
                                       line=bad,
                                       column=bad,
                                       expression=bad,
                                       warnings=('watch out', bad),
                                       getInfo=lambda: bad),
                       info=bad), MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url=None,
              line=None,
              column=None,
              expression=None,
              warnings=['watch out'],
              extra=None), supplement)
     self.assertIs(None, info)
Ejemplo n.º 11
0
 def test_get_frame_data_broken_str(self):
     bad = BadString()
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(
                 supplement=dict(
                     source_url=bad,
                     line=bad,
                     column=bad,
                     expression=bad,
                     warnings=('watch out', bad),
                     getInfo=lambda: bad
                 ),
                 info=bad),
             MY_LINE_NUMBER))
     self.assertEqual(
         dict(source_url=None, line=None, column=None,
              expression=None, warnings=['watch out'], extra=None),
         supplement)
     self.assertIs(None, info)
Ejemplo n.º 12
0
 def test_get_frame_data_supplement_bad_getInfo_with_traceback(self):
     def boo_hiss():
         raise ValueError()
     original_stderr = sys.__stderr__
     stderr = sys.stderr = StringIO.StringIO()
     self.assertFalse(stacktrace.DEBUG_EXCEPTION_FORMATTER)
     stacktrace.DEBUG_EXCEPTION_FORMATTER = True
     try:
         filename, lineno, name, line, modname, supplement, info = (
             stacktrace._get_frame_data(
                 get_frame(supplement=dict(getInfo=boo_hiss)),
                 MY_LINE_NUMBER))
     finally:
         sys.stderr = original_stderr
         stacktrace.DEBUG_EXCEPTION_FORMATTER = False
     self.assertEqual(
         dict(source_url=None, line=None, column=None, expression=None,
              warnings=[], extra=None),
         supplement)
     self.assertIn('boo_hiss', stderr.getvalue())
Ejemplo n.º 13
0
    def test_get_frame_data_supplement_bad_getInfo_with_traceback(self):
        def boo_hiss():
            raise ValueError()

        original_stderr = sys.__stderr__
        stderr = sys.stderr = StringIO.StringIO()
        self.assertFalse(stacktrace.DEBUG_EXCEPTION_FORMATTER)
        stacktrace.DEBUG_EXCEPTION_FORMATTER = True
        try:
            filename, lineno, name, line, modname, supplement, info = (
                stacktrace._get_frame_data(
                    get_frame(supplement=dict(getInfo=boo_hiss)),
                    MY_LINE_NUMBER))
        finally:
            sys.stderr = original_stderr
            stacktrace.DEBUG_EXCEPTION_FORMATTER = False
        self.assertEqual(
            dict(source_url=None,
                 line=None,
                 column=None,
                 expression=None,
                 warnings=[],
                 extra=None), supplement)
        self.assertIn('boo_hiss', stderr.getvalue())
Ejemplo n.º 14
0
 def test_get_frame_data_info(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(info='foo bar'), MY_LINE_NUMBER))
     self.assertEqual('foo bar', info)
Ejemplo n.º 15
0
 def test_get_frame_data_info(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(get_frame(info='foo bar'),
                                    MY_LINE_NUMBER))
     self.assertEqual('foo bar', info)
Ejemplo n.º 16
0
 def test_get_frame_data_broken_warnings(self):
     filename, lineno, name, line, modname, supplement, info = (
         stacktrace._get_frame_data(
             get_frame(supplement=dict(warnings=object())), MY_LINE_NUMBER))
     self.assertEqual([], supplement['warnings'])