Python py.test:在Jenkins中显示局部变量
到目前为止,我们通过Jenkins调用Python py.test:在Jenkins中显示局部变量,python,django,jenkins,pytest,sentry,Python,Django,Jenkins,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':", ...] 如果
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调试页面中看到局部变量(请参阅),那将非常棒
。。。。但只有在我想看到它们的时候,它们才应该是可见的。我想这意味着我需要一种不同于文本的格式。也许是HTML
有没有办法实现这一点
我从来没有用过哨兵的工具。但是,这样可以显示带有局部变量的良好回溯。使用
-l
/--showlocals
选项:
例如:
def foo():
a = 1
> assert 0
E assert 0
a = 1
test_foo.py:8: AssertionError
请参阅。moidule
cgib
可以帮助-在页面顶部插入cgib.enable(format='text',context=12)
module@CharlesPehlivanian是的,这可能有用。但这会使默认印象膨胀。我只想有时看到局部变量。如果我总是看到它们,那么日常工作就会变得有点困难……就像在djangobook页面上使用下拉菜单一样?纯文本无法做到这一点,不知道存在什么样的服务…@CharlesPehlivanian你称之为“服务”。我认为您需要两个部分:一个部分创建带有更详细信息的回溯,另一个部分将其呈现为HTML。我没有尝试过这一点,但是cgib.enable(format='HTML')
可能会满足您的需要。试试看。我只想偶尔看看局部变量。如果我总是看到它们,那么日常工作就会变得有点困难。好吧,但我对所有CI都有这个选项,这非常有用。@guettli,它可以被捕获,也可以不被捕获。在运行测试之前,在不更改某些配置的情况下如何定义?
def foo():
a = 1
> assert 0
E assert 0
a = 1
test_foo.py:8: AssertionError