到目前为止,我们通过 Jenkins 调用 py.test
。
如果测试失败,我们会看到像这样的通常的堆栈跟踪
Traceback (most recent call last):
File "/home/u/src/foo/bar/tests/test_x.py", line 36, in test_schema_migrations
errors, out))
AssertionError: Unknown output: ["Migrations for 'blue':", ...]
如果我能像在 Django 调试页面中那样看到局部变量(参见 https://djangobook.com/wp-content/uploads/figure2_3a.png),那就太好了。
.... 但只有当我想看到它们时,它们才应该可见。我想这意味着我需要一种不同于文本的格式。也许是 HTML?
有没有办法启用它?
我从未使用过 Sentry 这个工具。但是据我所知,这可以显示带有局部变量的很好的回溯。
最佳答案
使用-l
/--showlocals
选项:
pytest --showlocals # show local variables in tracebacks pytest -l # show local variables (shortcut)
例子:
def foo():
a = 1
> assert 0
E assert 0
a = 1
test_foo.py:8: AssertionError
关于python - py.test : Show local variables in Jenkins,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47674185/