1

I want to 'always' break on AssertionError, except for certain locations. E.g. ..site-packages/_pytest/config/__init__.py an exception is thrown just to check whether assertions are activated:

def _assertion_supported():
  try:
    assert False
  except AssertionError:
    return True
  else:
    return False

Is there a way to say "always break on AssertionError except for those locations"?

4

1 回答 1

1

如果您在 Debugger > Exceptions > Always Report 首选项中有 AssertionError,那么在达到断言后,您可以检查 Exceptions 工具中的“忽略此异常位置”并继续调试。该断言不应再次报告,但其他人会。

当然,如果断言不是由 try/except 处理的,那么它仍然可能会终止您的调试过程,就像在调试器之外运行时一样。

于 2019-01-24T16:20:37.783 回答