py.test:在Jenkins中显示局部变量

gue*_*tli 10 python django pytest sentry 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':", ...] 
Run Code Online (Sandbox Code Playgroud)

如果我能看到django调试页面中的局部变量(请参阅https://djangobook.com/wp-content/uploads/figure2_3a.png),那真的很棒.

......但是如果我想看到它们,它们应该只是可见的.我想这意味着我需要一种不同于文本的格式.也许HTML?

有没有办法实现这个?

我从未使用过Sentry工具.但是AFAIK可以显示带有局部变量的精美回溯.

geo*_*xsh 8

使用-l/ --showlocals选项:

pytest --showlocals # show local variables in tracebacks
pytest -l           # show local variables (shortcut)
Run Code Online (Sandbox Code Playgroud)

例:

    def foo():
        a = 1
>       assert 0
E       assert 0

a          = 1

test_foo.py:8: AssertionError
Run Code Online (Sandbox Code Playgroud)

在doc中查看更多详细信息.