Ejemplo n.º 1
0
    def test_get_hash_ignores_javassist(self):
        interface = Frame.to_python({
            'module':
            'com.example.api.entry.EntriesResource_$$_javassist_seam_74',
            'function': 'fn',
        })
        result = interface.get_hash(platform='java')
        self.assertEquals(
            result,
            ['com.example.api.entry.EntriesResource_$$_javassist<auto>', 'fn'])

        interface = Frame.to_python({
            'module': 'com.example.api.entry.EntriesResource_$$_javassist_74',
            'function': 'fn',
        })
        result = interface.get_hash(platform='java')
        self.assertEquals(
            result,
            ['com.example.api.entry.EntriesResource_$$_javassist<auto>', 'fn'])

        interface = Frame.to_python({
            'filename': 'EntriesResource_$$_javassist_seam_74.java',
            'function': 'fn',
        })
        result = interface.get_hash(platform='java')
        self.assertEquals(result,
                          ['EntriesResource_$$_javassist<auto>.java', 'fn'])
    def test_get_hash_sanitizes_versioned_filenames(self):
        # This is Ruby specific
        interface = Frame.to_python({
            'filename':
            '/data/foo/releases/20140114151955/app/views/foo.html.erb',
            'context_line':
            '<% if @hotels.size > 0 %>',
        })
        result = interface.get_hash()
        self.assertEquals(result, [
            '/data/foo/releases/<version>/app/views/foo.html.erb',
            '<% if @hotels.size > 0 %>',
        ])

        interface = Frame.to_python({
            'filename':
            '20140114151955/app/views/foo.html.erb',
            'context_line':
            '<% if @hotels.size > 0 %>',
        })
        result = interface.get_hash()
        self.assertEquals(result, [
            '<version>/app/views/foo.html.erb',
            '<% if @hotels.size > 0 %>',
        ])
Ejemplo n.º 3
0
 def test_context_with_nan(self):
     self.assertEquals(
         Frame.to_python({
             'filename': 'x',
             'vars': {
                 'x': float('inf')
             },
         }).vars,
         {'x': '<inf>'},
     )
     self.assertEquals(
         Frame.to_python({
             'filename': 'x',
             'vars': {
                 'x': float('-inf')
             },
         }).vars,
         {'x': '<-inf>'},
     )
     self.assertEquals(
         Frame.to_python({
             'filename': 'x',
             'vars': {
                 'x': float('nan')
             },
         }).vars,
         {'x': '<nan>'},
     )
Ejemplo n.º 4
0
 def test_context_with_nan(self):
     self.assertEquals(
         Frame.to_python({
             'filename': 'x',
             'vars': {
                 'x': float('inf')
             },
         }).vars,
         {'x': '<inf>'},
     )
     self.assertEquals(
         Frame.to_python({
             'filename': 'x',
             'vars': {
                 'x': float('-inf')
             },
         }).vars,
         {'x': '<-inf>'},
     )
     self.assertEquals(
         Frame.to_python({
             'filename': 'x',
             'vars': {
                 'x': float('nan')
             },
         }).vars,
         {'x': '<nan>'},
     )
Ejemplo n.º 5
0
    def test_bad_input(self):
        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'filename': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'filename': 'foo',
                'abs_path': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'function': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'module': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'function': '?',
            })
Ejemplo n.º 6
0
    def test_bad_input(self):
        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'filename': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'filename': 'foo',
                'abs_path': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'function': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'module': 1,
            })

        with self.assertRaises(InterfaceValidationError):
            Frame.to_python({
                'function': '?',
            })
Ejemplo n.º 7
0
    def test_get_hash_sanitizes_versioned_filenames(self):
        # This is Ruby specific
        interface = Frame.to_python(
            {
                'filename': '/data/foo/releases/20140114151955/app/views/foo.html.erb',
                'context_line': '<% if @hotels.size > 0 %>',
            }
        )
        result = interface.get_hash()
        self.assertEquals(
            result, [
                '/data/foo/releases/<version>/app/views/foo.html.erb',
                '<% if @hotels.size > 0 %>',
            ]
        )

        interface = Frame.to_python(
            {
                'filename': '20140114151955/app/views/foo.html.erb',
                'context_line': '<% if @hotels.size > 0 %>',
            }
        )
        result = interface.get_hash()
        self.assertEquals(
            result, [
                '<version>/app/views/foo.html.erb',
                '<% if @hotels.size > 0 %>',
            ]
        )
Ejemplo n.º 8
0
 def test_get_hash_sanitizes_erb_templates(self):
     # This is Ruby specific
     interface = Frame.to_python(
         {"filename": "foo.html.erb", "function": "_foo_html_erb__3327151541118998292_70361296749460"}
     )
     result = interface.get_hash()
     self.assertEquals(result, ["foo.html.erb", "_foo_html_erb__<anon>_<anon>"])
Ejemplo n.º 9
0
    def test_get_hash_sanitizes_versioned_filenames(self):
        # This is Ruby specific
        interface = Frame.to_python(
            {
                "filename": "/data/foo/releases/20140114151955/app/views/foo.html.erb",
                "context_line": "<% if @hotels.size > 0 %>",
            }
        )
        result = interface.get_hash()
        self.assertEquals(result, ["/data/foo/releases/<version>/app/views/foo.html.erb", "<% if @hotels.size > 0 %>"])

        interface = Frame.to_python(
            {"filename": "20140114151955/app/views/foo.html.erb", "context_line": "<% if @hotels.size > 0 %>"}
        )
        result = interface.get_hash()
        self.assertEquals(result, ["<version>/app/views/foo.html.erb", "<% if @hotels.size > 0 %>"])
Ejemplo n.º 10
0
 def test_get_hash_ignores_filename_if_blob(self):
     interface = Frame.to_python({
         'filename':
         'blob:http://example.com/7f7aaadf-a006-4217-9ed5-5fbf8585c6c0',
     })
     result = interface.get_hash()
     self.assertEquals(result, [])
Ejemplo n.º 11
0
 def test_get_hash_with_only_required_vars(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo.py', 1])
Ejemplo n.º 12
0
 def test_get_hash_ignores_filename_if_https(self):
     interface = Frame.to_python({
         'context_line': 'hello world',
         'filename': 'https://foo.com/foo.py',
     })
     result = interface.get_hash()
     self.assertEquals(result, ['hello world'])
Ejemplo n.º 13
0
 def test_get_hash_with_only_required_vars(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo.py', 1])
Ejemplo n.º 14
0
 def test_get_hash_ignores_filename_if_https(self):
     interface = Frame.to_python({
         'context_line': 'hello world',
         'filename': 'https://foo.com/foo.py',
     })
     result = interface.get_hash()
     self.assertEquals(result, ['hello world'])
Ejemplo n.º 15
0
 def test_compute_hashes_with_only_required_vars(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
     })
     result = interface.compute_hashes()
     self.assertEquals(result, [['foo.py', 1]])
Ejemplo n.º 16
0
 def test_get_hash_ignores_safari_native_code(self):
     interface = Frame.to_python({
         'abs_path': '[native code]',
         'filename': '[native code]',
         'function': 'forEach',
     })
     result = interface.get_hash()
     self.assertEquals(result, [])
Ejemplo n.º 17
0
 def test_get_hash_uses_module_over_filename(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
         'module': 'foo'
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo', 1])
Ejemplo n.º 18
0
 def test_compute_hashes_ignores_safari_native_code(self):
     interface = Frame.to_python({
         'abs_path': '[native code]',
         'filename': '[native code]',
         'function': 'forEach',
     })
     result = interface.compute_hashes()
     self.assertEquals(result, [])
Ejemplo n.º 19
0
 def test_get_hash_uses_function_over_lineno(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
         'function': 'bar'
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo.py', 'bar'])
Ejemplo n.º 20
0
 def test_get_hash_sanitizes_block_functions(self):
     # This is Ruby specific
     interface = Frame.to_python({
         'filename': 'foo.py',
         'function': 'block in _conditional_callback_around_233',
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo.py', 'block'])
Ejemplo n.º 21
0
 def test_compute_hashes_ignores_filename_if_https(self):
     interface = Frame.to_python({
         'context_line': 'hello world',
         'filename': 'https://foo.com/foo.py',
         'function': 'test',
     })
     result = interface.compute_hashes()
     self.assertEquals(result, [['hello world']])
Ejemplo n.º 22
0
 def test_get_hash_uses_module_over_filename(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
         'module': 'foo'
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo', 1])
Ejemplo n.º 23
0
 def test_get_hash_sanitizes_block_functions(self):
     # This is Ruby specific
     interface = Frame.to_python({
         'filename': 'foo.py',
         'function': 'block in _conditional_callback_around_233',
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo.py', 'block'])
Ejemplo n.º 24
0
 def test_get_hash_uses_function_over_lineno(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'foo.py',
         'function': 'bar'
     })
     result = interface.get_hash()
     self.assertEquals(result, ['foo.py', 'bar'])
Ejemplo n.º 25
0
 def test_get_hash_ignores_filename_if_blob(self):
     interface = Frame.to_python(
         {
             'filename': 'blob:http://example.com/7f7aaadf-a006-4217-9ed5-5fbf8585c6c0',
         }
     )
     result = interface.get_hash()
     self.assertEquals(result, [])
Ejemplo n.º 26
0
 def test_compute_hashes_uses_context_line_over_function(self):
     interface = Frame.to_python({
         'context_line': 'foo bar',
         'lineno': 1,
         'filename': 'foo.py',
         'function': 'bar'
     })
     result = interface.compute_hashes()
     self.assertEquals(result, [['foo.py', 'foo bar']])
Ejemplo n.º 27
0
 def test_get_hash_ignores_extra_ENHANCED_clojure_classes(self):
     interface = Frame.to_python({
         'module': 'sentry_clojure_example.core$_main$fn__1539$fn__1540',
         'function': 'invoke'
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'sentry_clojure_example.core$_main$fn__<auto>$fn__<auto>',
         'invoke',
     ])
Ejemplo n.º 28
0
 def test_compute_hashes_ignores_extra_ENHANCED_clojure_classes(self):
     interface = Frame.to_python({
         'module': 'sentry_clojure_example.core$_main$fn__1539$fn__1540',
         'function': 'invoke'
     })
     result = interface.compute_hashes(platform='java')
     self.assertEquals(result, [[
         'sentry_clojure_example.core$_main$fn__<auto>$fn__<auto>',
         'invoke',
     ]])
Ejemplo n.º 29
0
 def test_get_hash_ignores_java8_lambda_function(self):
     interface = Frame.to_python({
         'module': 'foo.bar.Baz',
         'function': 'lambda$work$1',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'foo.bar.Baz',
         '<function>',
     ])
Ejemplo n.º 30
0
 def test_get_hash_ignores_ENHANCED_clojure_classes(self):
     interface = Frame.to_python({
         'module': 'sentry_clojure_example.core$_main$fn__1539',
         'function': 'invoke'
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'sentry_clojure_example.core$_main$fn__<auto>',
         'invoke',
     ])
Ejemplo n.º 31
0
 def test_get_hash_ignores_sun_java_generated_methods(self):
     interface = Frame.to_python({
         'module': 'sun.reflect.GeneratedMethodAccessor12345',
         'function': 'invoke',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'sun.reflect.GeneratedMethodAccessor',
         'invoke',
     ])
Ejemplo n.º 32
0
 def test_compute_hashes_ignores_sun_java_generated_methods(self):
     interface = Frame.to_python({
         'module': 'sun.reflect.GeneratedMethodAccessor12345',
         'function': 'invoke',
     })
     result = interface.compute_hashes(platform='java')
     self.assertEquals(result, [[
         'sun.reflect.GeneratedMethodAccessor',
         'invoke',
     ]])
Ejemplo n.º 33
0
 def test_get_hash_ignores_java8_lambda_module(self):
     interface = Frame.to_python({
         'module': 'foo.bar.Baz$$Lambda$40/1673859467',
         'function': 'call',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         '<module>',
         'call',
     ])
Ejemplo n.º 34
0
 def test_get_hash_ignores_java8_lambda_module(self):
     interface = Frame.to_python({
         'module': 'foo.bar.Baz$$Lambda$40/1673859467',
         'function': 'call',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         '<module>',
         'call',
     ])
Ejemplo n.º 35
0
 def test_get_hash_ignores_sun_java_generated_methods(self):
     interface = Frame.to_python({
         'module': 'sun.reflect.GeneratedMethodAccessor12345',
         'function': 'invoke',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'sun.reflect.GeneratedMethodAccessor',
         'invoke',
     ])
Ejemplo n.º 36
0
 def test_compute_hashes_ignores_java8_lambda_module(self):
     interface = Frame.to_python({
         'module': 'foo.bar.Baz$$Lambda$40/1673859467',
         'function': 'call',
     })
     result = interface.compute_hashes(platform='java')
     self.assertEquals(result, [[
         '<module>',
         'call',
     ]])
Ejemplo n.º 37
0
 def test_get_hash_sanitizes_erb_templates(self):
     # This is Ruby specific
     interface = Frame.to_python({
         'filename': 'foo.html.erb',
         'function': '_foo_html_erb__3327151541118998292_70361296749460',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'foo.html.erb', '_foo_html_erb__<anon>_<anon>',
     ])
Ejemplo n.º 38
0
 def test_get_hash_sanitizes_erb_templates(self):
     # This is Ruby specific
     interface = Frame.to_python({
         'filename': 'foo.html.erb',
         'function': '_foo_html_erb__3327151541118998292_70361296749460',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'foo.html.erb', '_foo_html_erb__<anon>_<anon>',
     ])
Ejemplo n.º 39
0
 def test_get_hash_ignores_java8_lambda_function(self):
     interface = Frame.to_python({
         'module': 'foo.bar.Baz',
         'function': 'lambda$work$1',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'foo.bar.Baz',
         '<function>',
     ])
Ejemplo n.º 40
0
 def test_get_hash_skips_symbol_if_unknown(self):
     interface = Frame.to_python({
         'module': 'libfoo',
         'function': 'main',
         'symbol': '?',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'libfoo',
         'main',
     ])
Ejemplo n.º 41
0
 def test_get_hash_uses_symbol_instead_of_function(self):
     interface = Frame.to_python({
         'module': 'libfoo',
         'function': 'int main()',
         'symbol': '_main',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'libfoo',
         '_main',
     ])
Ejemplo n.º 42
0
    def test_compute_hashes_ignores_sun_java_generated_constructors(self):
        interface = Frame.to_python({
            'module': 'sun.reflect.GeneratedSerializationConstructorAccessor1',
            'function': 'invoke',
        })
        result = interface.compute_hashes(platform='java')
        self.assertEquals(result, [[
            'sun.reflect.GeneratedSerializationConstructorAccessor<auto>',
            'invoke',
        ]])

        interface = Frame.to_python({
            'module': 'sun.reflect.GeneratedConstructorAccessor2',
            'function': 'invoke',
        })
        result = interface.compute_hashes(platform='java')
        self.assertEquals(result, [[
            'sun.reflect.GeneratedConstructorAccessor<auto>',
            'invoke',
        ]])
Ejemplo n.º 43
0
 def test_compute_hashes_uses_symbol_instead_of_function(self):
     interface = Frame.to_python({
         'module': 'libfoo',
         'function': 'int main()',
         'symbol': '_main',
     })
     result = interface.compute_hashes()
     self.assertEquals(result, [[
         'libfoo',
         '_main',
     ]])
Ejemplo n.º 44
0
 def test_get_hash_skips_symbol_if_unknown(self):
     interface = Frame.to_python({
         'module': 'libfoo',
         'function': 'main',
         'symbol': '?',
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'libfoo',
         'main',
     ])
Ejemplo n.º 45
0
 def test_get_hash_ignores_ENHANCED_spring_classes(self):
     interface = Frame.to_python({
         'module': 'invalid.gruml.talkytalkyhub.common.config.'
         'JipJipConfig$$EnhancerBySpringCGLIB$$1ebdddb0',
         'function': 'jipJipManagementApplication'
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'invalid.gruml.talkytalkyhub.common.config.JipJipConfig'
         '$$EnhancerBySpringCGLIB$$<auto>',
         'jipJipManagementApplication',
     ])
Ejemplo n.º 46
0
 def test_address_normalization(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'blah.c',
         'function': 'main',
         'instruction_addr': 123456,
         'symbol_addr': '123450',
         'image_addr': '0x0',
     })
     assert interface.instruction_addr == '0x1e240'
     assert interface.symbol_addr == '0x1e23a'
     assert interface.image_addr == '0x0'
Ejemplo n.º 47
0
 def test_get_hash_ignores_ENHANCED_spring_classes(self):
     interface = Frame.to_python({
         'module': 'invalid.gruml.talkytalkyhub.common.config.'
         'JipJipConfig$$EnhancerBySpringCGLIB$$1ebdddb0',
         'function': 'jipJipManagementApplication'
     })
     result = interface.get_hash()
     self.assertEquals(result, [
         'invalid.gruml.talkytalkyhub.common.config.JipJipConfig'
         '$$EnhancerBySpringCGLIB$$<auto>',
         'jipJipManagementApplication',
     ])
Ejemplo n.º 48
0
    def test_bad_input(self):
        assert Frame.to_python({
            'filename': 1,
        }).filename is None

        assert Frame.to_python({
            'filename': 'foo',
            'abs_path': 1,
        }).abs_path == 'foo'

        assert Frame.to_python({
            'function': 1,
        }).function is None

        assert Frame.to_python({
            'module': 1,
        }).module is None

        assert Frame.to_python({
            'function': '?',
        }).function is None
Ejemplo n.º 49
0
 def test_address_normalization(self):
     interface = Frame.to_python({
         'lineno': 1,
         'filename': 'blah.c',
         'function': 'main',
         'instruction_addr': 123456,
         'symbol_addr': '123450',
         'image_addr': '0x0',
     })
     assert interface.instruction_addr == '0x1e240'
     assert interface.symbol_addr == '0x1e23a'
     assert interface.image_addr == '0x0'
Ejemplo n.º 50
0
    def test_get_hash_ignores_javassist(self):
        interface = Frame.to_python(
            {
                'module': 'com.example.api.entry.EntriesResource_$$_javassist_seam_74',
                'function': 'fn',
            }
        )
        result = interface.get_hash(platform='java')
        self.assertEquals(
            result, [
                'com.example.api.entry.EntriesResource_$$_javassist<auto>', 'fn'
            ]
        )

        interface = Frame.to_python(
            {
                'module': 'com.example.api.entry.EntriesResource_$$_javassist_74',
                'function': 'fn',
            }
        )
        result = interface.get_hash(platform='java')
        self.assertEquals(
            result, [
                'com.example.api.entry.EntriesResource_$$_javassist<auto>', 'fn'
            ]
        )

        interface = Frame.to_python(
            {
                'filename': 'EntriesResource_$$_javassist_seam_74.java',
                'function': 'fn',
            }
        )
        result = interface.get_hash(platform='java')
        self.assertEquals(
            result, [
                'EntriesResource_$$_javassist<auto>.java', 'fn'
            ]
        )
Ejemplo n.º 51
0
    def test_get_hash_ignores_module_if_page_url(self):
        """
        When the abs_path is a URL without a file extension, and the module is
        a suffix of that URL, we should ignore the module. This takes care of a
        raven-js issue where page URLs (not source filenames) are being used as
        the module.
        """

        interface = Frame.to_python({
            'filename': 'foo.py',
            'abs_path': 'https://sentry.io/foo/bar/baz.js',
            'module': 'foo/bar/baz',
        })
        result = interface.get_hash(platform='javascript')
        assert result == ['foo/bar/baz']

        interface = Frame.to_python({
            'filename': 'foo.py',
            'abs_path': 'https://sentry.io/foo/bar/baz',
            'module': 'foo/bar/baz',
        })
        result = interface.get_hash(platform='javascript')
        assert result == ['<module>']
Ejemplo n.º 52
0
    def test_get_hash_ignores_module_if_page_url(self):
        """
        When the abs_path is a URL without a file extension, and the module is
        a suffix of that URL, we should ignore the module. This takes care of a
        raven-js issue where page URLs (not source filenames) are being used as
        the module.
        """

        interface = Frame.to_python({
            'filename': 'foo.py',
            'abs_path': 'https://sentry.io/foo/bar/baz.js',
            'module': 'foo/bar/baz',
        })
        result = interface.get_hash(platform='javascript')
        assert result == ['foo/bar/baz']

        interface = Frame.to_python({
            'filename': 'foo.py',
            'abs_path': 'https://sentry.io/foo/bar/baz',
            'module': 'foo/bar/baz',
        })
        result = interface.get_hash(platform='javascript')
        assert result == ['<module>']
Ejemplo n.º 53
0
 def test_compute_hashes_ignores_extra_ENHANCED_spring_classes(self):
     interface = Frame.to_python({
         'module':
         'invalid.gruml.talkytalkyhub.common.config.'
         'JipJipConfig$$EnhancerBySpringCGLIB$$1ebdddb0'
         '$$EnhancerBySpringCGLIB$$8219cd38'
         '$$FastClassBySpringCGLIB$$6c0b35d1',
         'function':
         'jipJipManagementApplication'
     })
     result = interface.compute_hashes(platform='java')
     self.assertEquals(result, [[
         'invalid.gruml.talkytalkyhub.common.config.JipJipConfig'
         '$$EnhancerBySpringCGLIB$$<auto>$$EnhancerBySpringCGLIB$$<auto>'
         '$$FastClassBySpringCGLIB$$<auto>',
         'jipJipManagementApplication',
     ]])
Ejemplo n.º 54
0
    def format_chrome_ie_frame(self, frame):
        tokens = JavascriptLiteSourceProcessor.chrome_ie_stacktrace_expr.findall(frame)[0]

        frame = {
            'filename': tokens[1],
            'function': tokens[0] or '?',
            'in_app': True,
        }

        try:
            frame['lineno'] = int(float(tokens[2]))
        except:
            pass

        try:
            frame['colno'] = int(float(tokens[3]))
        except:
            pass

        return Frame.to_python(frame)
Ejemplo n.º 55
0
    def format_firefox_safari_frame(self, frame):
        tokens = JavascriptLiteSourceProcessor.firefox_safari_stacktrace_expr.findall(frame)[0]

        frame = {
            'filename': tokens[2],
            'function': tokens[0] or '?',
            'in_app': True,
        }

        if tokens[1]:
            frame['args'] = tokens[1].split(',')

        try:
            frame['lineno'] = int(float(tokens[3]))
        except:
            pass

        try:
            frame['colno'] = int(float(tokens[4]))
        except:
            pass

        return Frame.to_python(frame)
Ejemplo n.º 56
0
 def test_get_hash_with_only_required_vars(self):
     interface = Frame.to_python({"lineno": 1, "filename": "foo.py"})
     result = interface.get_hash()
     self.assertEquals(result, ["foo.py", 1])
Ejemplo n.º 57
0
 def test_get_hash_uses_context_line_over_function(self):
     interface = Frame.to_python({"context_line": "foo bar", "lineno": 1, "filename": "foo.py", "function": "bar"})
     result = interface.get_hash()
     self.assertEquals(result, ["foo.py", "foo bar"])
Ejemplo n.º 58
0
 def test_get_hash_ignores_java8_lambda_function(self):
     interface = Frame.to_python({"module": "foo.bar.Baz", "function": "lambda$work$1"})
     result = interface.get_hash()
     self.assertEquals(result, ["foo.bar.Baz", "<function>"])
Ejemplo n.º 59
0
 def test_get_hash_uses_module_over_filename(self):
     interface = Frame.to_python({"lineno": 1, "filename": "foo.py", "module": "foo"})
     result = interface.get_hash()
     self.assertEquals(result, ["foo", 1])
Ejemplo n.º 60
0
 def test_get_hash_ignores_filename_if_abs_path_is_http(self):
     interface = Frame.to_python(
         {"context_line": "hello world", "abs_path": "https://foo.com/foo.py", "filename": "foo.py"}
     )
     result = interface.get_hash()
     self.assertEquals(result, ["hello world"])