NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

test_eve_exception_handler.py (2579B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\sys\test\test_eve_exception_handler.py
      2 from log import LGERR
      3 from mock import Mock, patch
      4 from sys import exc_info
      5 from testsuites.testcases import ClientTestCase
      6 
      7 class EveExceptionHandlerTests(ClientTestCase):
      8     MOCK_UI_CONTEXT = 'active=walletWindow focused=OverviewPanel'
      9     MOCK_TASKLET_STACK = ['\n    File "D:/perforce/eve/branches/sandbox/2025-PROTO-IMPORTS/packages\x08luepy\\__init__.py", line 54, in CallWrapper\n      return method(*args, **kwds)\n    ',
     10      '\n    File "D:/perforce/eve/branches/sandbox/2025-PROTO-IMPORTS\\eve\\client\\script\\ui\\shared\neocom\\wallet\\walletWnd.py", line 69, in trigger_blocked_tasklet\n      e.ExceptionHandler(exctype, exc, tb, message=\'BeResMan\')\n    ',
     11      '\n    File "D:\\perforce\\eve\x08ranches\\sandbox\x825-PROTO-IMPORTS\\eve\\client\\script\\sys\\eve_exception_handler.py", line 271, in ExceptionHandler\n      extraText = self._BuildContext(exc, message)\n    ',
     12      '\n    File "D:\\perforce\\eve\x08ranches\\sandbox\x825-PROTO-IMPORTS\\eve\\client\\script\\sys\\eve_exception_handler.py", line 310, in _BuildContext\n      taskletStackContext = self._GetTaskletStackContext(exc)\n    ',
     13      '\n    File "D:\\perforce\\eve\x08ranches\\sandbox\x825-PROTO-IMPORTS\\eve\\client\\script\\sys\\eve_exception_handler.py", line 323, in _GetTaskletStackContext\n      stack = traceback.format_stack(frame)\n    ']
     14 
     15     def setUp(self):
     16         with patch.dict('sys.modules', self._mock_imported_modules()):
     17             from eve.client.script.sys import eve_exception_handler
     18             self.eve = eve_exception_handler
     19             self.eve._ShouldShowExceptions = Mock(return_value=False)
     20             self.eve._GetUiContext = Mock(return_value=self.MOCK_UI_CONTEXT)
     21             self.eve._GetTaskletStack = Mock(return_value=''.join(self.MOCK_TASKLET_STACK[-2:]))
     22 
     23     def _mock_imported_modules(self):
     24         return {'trinity': Mock()}
     25 
     26     def test_this_tasklet_does_not_like_to_be_blocked_exception_logs_some_context(self):
     27         self.eve._LogException = Mock()
     28         try:
     29             raise RuntimeError('this tasklet does not like to be blocked.')
     30         except RuntimeError:
     31             exctype, exc, tb = exc_info()
     32             message = 'BeResMan'
     33             self.eve.handle_exception(exctype=exctype, exc=exc, tb=tb, message=message)
     34             self.eve._LogException.assert_called_once_with(extraText=self.eve._BuildContext(exc, message), toMsgWindow=0, exctype=exctype, exc=exc, tb=tb, severity=LGERR)