到目前为止,我们通过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工具。但是AFAIK可以显示带有局部变量的精美回溯。
使用-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