File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
linux/keyman-config/keyman_config Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 55import os
66import platform
77import sys
8+ import traceback
89from keyman_config .version import (
910 __version__ ,
1011 __versionwithtag__ ,
@@ -47,7 +48,7 @@ def initialize_sentry(self):
4748 return (True , '' )
4849
4950 def is_sentry_enabled (self ):
50- if 'unittest' in sys . modules . keys ():
51+ if self . _is_unit_test ():
5152 return (False , 'Running unit tests, not reporting to Sentry' )
5253 elif self ._get_environ_nosentry ():
5354 return (False , 'Not reporting to Sentry because KEYMAN_NOSENTRY environment variable set' )
@@ -75,6 +76,14 @@ def _get_environ_nosentry(self):
7576 keyman_nosentry = os .environ .get ('KEYMAN_NOSENTRY' )
7677 return keyman_nosentry and (int (keyman_nosentry ) == 1 )
7778
79+ def _is_unit_test (self ): # sourcery skip: use-any, use-next
80+ # The suggested refactorings (using any() or next()) don't work
81+ # when testing on Ubuntu 20.04
82+ for line in traceback .format_stack ():
83+ if '/unittest/' in line :
84+ return True
85+ return False
86+
7887 def _handle_enabled (self , enabled ):
7988 if enabled :
8089 self .initialize_sentry ()
You can’t perform that action at this time.
0 commit comments