Получить ссылку на текущее исключение
$ ./runtests.py -v tests/managers/test_customer.py:CustomerManagerTest.test_register_without_subscription --ipdb
...
test_register_without_subscription (tests.managers.test_customer.CustomerManagerTest) ...
- TRACEBACK --------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "*****/tests/managers/test_customer.py", line 198, in test_register_without_subscription
1/0
ZeroDivisionError: integer division or modulo by zero
--------------------------------------------------------------------------------
> *****/tests/managers/test_customer.py(198)test_register_without_subscription()
197 def test_register_without_subscription(self):
--> 198 1/0
199 ...
ipdb> import sys
ipdb> sys.exc_info()
(, AttributeError("Pdb instance has no attribute 'do_sys'",), )
ipdb>
Я не мог найти ни одной команды вipdb help
это показывает мне текущее исключение.
делаimport sys; print sys.exc_info()
Безразлично»т работа.
В настоящее время я делаю:
try:
do_something_that_raises_an_exception()
except Exception as exc:
import ipdb; ipdb.set_trace()
тогда я могу работать сexc
проанализировать это.
Какбез труда получить ссылку на действующее в настоящее время исключение?