How to use the bugsnag.configuration.Configuration function in bugsnag

To help you get started, we’ve selected a few bugsnag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-python / tests / test_notification.py View on Github external
def test_code_at_start_of_file(self):

        config = Configuration()
        notification = Notification(fixtures.start_of_file[1], config, {},
                                    traceback=fixtures.start_of_file[2])

        payload = json.loads(notification._payload())

        code = payload['events'][0]['exceptions'][0]['stacktrace'][0]['code']
        self.assertEqual(
            {'1': '# flake8: noqa',
             '2': 'try:',
             '3': '    import sys; raise Exception("start")',
             '4': 'except Exception: start_of_file = sys.exc_info()',
             '5': '# 4',
             '6': '# 5',
             '7': '# 6'}, code)
github bugsnag / bugsnag-python / tests / test_configuration.py View on Github external
def test_custom_get_endpoint_use_ssl(self):
        c = Configuration()
        c.use_ssl = True
        c.endpoint = "localhost:1234"
        self.assertEqual(c.get_endpoint(), "https://localhost:1234")
github bugsnag / bugsnag-python / tests / test_configuration.py View on Github external
def test_hostname(self):
        c = Configuration()
        self.assertEqual(c.hostname, socket.gethostname())

        os.environ["DYNO"] = "YES"
        c = Configuration()
        self.assertEqual(c.hostname, None)
github bugsnag / bugsnag-python / tests / test_notification.py View on Github external
def test_traceback_exclude_modules(self):
        # Make sure samples.py is compiling to pyc
        import py_compile
        py_compile.compile('./fixtures/helpers.py')

        from tests.fixtures import helpers
        reload(helpers)  # .py variation might be loaded from previous test.

        if sys.version_info < (3, 0):
            # Python 2.6 & 2.7 returns the cached file on __file__,
            # and hence we verify it returns .pyc for these versions
            # and the code at _generate_stacktrace() handles that.
            self.assertTrue(helpers.__file__.endswith('.pyc'))

        config = Configuration()
        config.traceback_exclude_modules = [helpers]

        notification = helpers.invoke_exception_on_other_file(config)

        payload = json.loads(notification._payload())
        exception = payload['events'][0]['exceptions'][0]
        first_traceback = exception['stacktrace'][0]
        self.assertEqual(first_traceback['file'], 'test_notification.py')
github bugsnag / bugsnag-python / tests / test_notification.py View on Github external
def test_sanitize(self):
        """
            It should sanitize request data
        """
        config = Configuration()
        notification = Notification(Exception("oops"), config, {},
                                    request={"params": {"password": "secret"}})

        notification.add_tab("request", {"arguments": {"password": "secret"}})

        payload = json.loads(notification._payload())
        request = payload['events'][0]['metaData']['request']
        self.assertEqual(request['arguments']['password'], '[FILTERED]')
        self.assertEqual(request['params']['password'], '[FILTERED]')
github bugsnag / bugsnag-python / tests / test_path_encoding.py View on Github external
def test_path_supports_emoji(self):
        import bugsnag.wsgi.middleware

        environ = self.environ.copy()
        environ['PATH_INFO'] = '/😇'

        config = Configuration()
        notification = Notification(
            Exception("oops"),
            config,
            RequestConfiguration.get_instance()
        )

        bugsnag.configure_request(wsgi_environ=environ)

        bugsnag.wsgi.middleware.add_wsgi_request_data_to_notification(
            notification
        )

        # You can validate this by using "encodeURIComponent" in a browser.
        self.assertEqual(
            'http://localhost/%F0%9F%98%87',
            notification.meta_data['request']['url']
github bugsnag / bugsnag-python / tests / test_configuration.py View on Github external
def test_reads_api_key_from_environ(self):
        os.environ['BUGSNAG_API_KEY'] = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        c = Configuration()
        self.assertEqual(c.api_key, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        self.assertEqual(c.project_root, os.getcwd())
github bugsnag / bugsnag-python / tests / test_configuration.py View on Github external
def test_ignore_classes(self):
        # Test ignoring a class works
        c = Configuration()
        c.ignore_classes.append("SystemError")
        self.assertTrue(c.should_ignore(SystemError("Example")))

        c = Configuration()
        c.ignore_classes.append("SystemError")
        self.assertFalse(c.should_ignore(Exception("Example")))
github bugsnag / bugsnag-python / tests / test_configuration.py View on Github external
def test_custom_get_endpoint_no_use_ssl(self):
        c = Configuration()
        c.use_ssl = False
        c.endpoint = "localhost:1234"
        self.assertEqual(c.get_endpoint(), "http://localhost:1234")
github bugsnag / bugsnag-python / bugsnag / client.py View on Github external
def __init__(self, configuration=None, install_sys_hook=True, **kwargs):
        self.configuration = configuration or Configuration()
        self.session_tracker = SessionTracker(self.configuration)
        self.configuration.configure(**kwargs)

        if install_sys_hook:
            self.install_sys_hook()