小编Rah*_*hul的帖子

如何为pytest测试类的所有方法共享同一实例

我有一个简单的测试课

@pytest.mark.incremental
class TestXYZ:

    def test_x(self):
        print(self)

    def test_y(self):
        print(self)

    def test_z(self):
        print(self)
Run Code Online (Sandbox Code Playgroud)

运行此命令时,将得到以下输出:

test.TestXYZ对象位于0x7f99b729c9b0

test.TestXYZ对象位于0x7f99b7299b70

位于0x7f99b7287eb8的testTestXYZ对象

这表明在TestXYZ对象的3个不同实例上调用了3个方法。无论如何,有没有改变这种行为并使pytest在同一个对象实例上调用所有3个方法。这样我就可以使用self来存储一些值。

python pytest python-2.7 python-3.x

5
推荐指数
1
解决办法
601
查看次数

python如何知道当前线程是否持有锁

我有一个threading.Lock对象,我想知道是否current_thread持有这个锁.实现这一目标的最简单方法是什么?

python multithreading python-multithreading python-2.7

1
推荐指数
1
解决办法
4733
查看次数

Atlassian Bamboo如何识别python pytest报告

我有一些使用pytest用Python3编写的集成测试。我正在使用pytest-html从中生成html报告。我如何使Bamboo识别/显示此报告。

python bamboo pytest pytest-html

1
推荐指数
1
解决办法
1282
查看次数