summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Camba Garrido <ashwoods@gmail.com>2017-11-21 11:23:57 +0100
committerAshley Camba Garrido <ashwoods@gmail.com>2017-11-21 17:04:08 +0100
commitc6c95930d51e8f7a40b23b0f9d0b3cfb84723947 (patch)
treefc05fde26b82be1af4611084f884f1d82fe2f08b
parent30a849cbdd3ef87899f9e50d99a4f07419820e74 (diff)
downloadraven-feature-disable-dsn-explicit-none.tar.gz
Change behaviour of passing no argument to dsn is Nonefeature-disable-dsn-explicit-none
-rw-r--r--raven/base.py18
-rw-r--r--tests/base/tests.py6
2 files changed, 12 insertions, 12 deletions
diff --git a/raven/base.py b/raven/base.py
index 5509c58..0683768 100644
--- a/raven/base.py
+++ b/raven/base.py
@@ -248,30 +248,30 @@ class Client(object):
If dsn is explicitly set to None or given an empty string
as an environment variable it will disable reporting.
"""
+
if dsn is Ellipsis:
if 'SENTRY_DSN' in os.environ.keys():
msg = "Configuring Raven from environment variable 'SENTRY_DSN'"
self.logger.debug(msg)
dsn = os.environ['SENTRY_DSN']
else:
- raise ConfigurationError("Must pass valid DSN or set SENTRY_DSN Environment Variable")
+ dsn = None
+
+ if dsn:
+ if dsn in self._transport_cache:
+ self.remote = self._transport_cache[dsn]
- if dsn not in self._transport_cache:
- if not dsn:
- result = RemoteConfig(transport=transport)
else:
result = RemoteConfig.from_string(
dsn,
transport=transport,
)
- self._transport_cache[dsn] = result
- self.remote = result
- else:
- self.remote = self._transport_cache[dsn]
+ self._transport_cache[dsn] = result
+ self.remote = result
- if dsn is not None:
self.logger.debug("Configuring Raven for host: {0}".format(self.remote))
else:
+ self.remote = RemoteConfig(transport=transport)
self.logger.debug('Disabling raven because DSN set to None')
def install_sys_hook(self):
diff --git a/tests/base/tests.py b/tests/base/tests.py
index 23ab949..c023548 100644
--- a/tests/base/tests.py
+++ b/tests/base/tests.py
@@ -107,11 +107,11 @@ class ClientTest(TestCase):
DSN = ''
with mock.patch.dict(os.environ, {'SENTRY_DSN': DSN}):
client = Client()
- assert client.remote.get_public_dsn() is None
+ assert client.remote.is_active() is False
def test_client_explicit_none_dsn(self):
- client = Client(dsn=None)
- assert client.remote.get_public_dsn == ''
+ client = Client()
+ assert client.remote.is_active() is False
@mock.patch('raven.transport.http.HTTPTransport.send')
@mock.patch('raven.base.ClientState.should_try')