pytest之将多个测试用例放在一个类中,生成唯一临时文件夹
发布时间:2020-12-14 14:48:01 所属栏目:百科 来源:网络整理
导读:将多个测试用例放在一个类中 简单来说就是将多个测试用例放到类中,通过pytest去管理,这和Testng很像。示例代码如下: """ 将多个测试用例放到一个类中执行 """ class TestClass(object): def test_1(self): assert 1 == 1 def test_2(self): assert 'h' in
将多个测试用例放在一个类中简单来说就是将多个测试用例放到类中,通过pytest去管理,这和Testng很像。示例代码如下: """ 将多个测试用例放到一个类中执行 """ class TestClass(object): def test_1(self): assert 1 == 1 def test_2(self): assert 'h' in "hello" ? 执行效果 ? ? ? 创建唯一的临时文件夹内置?fixtures?之 tmpdir:
先写个测试用例,调用 tmpdir,示例代码如下: # -*- coding: utf-8 -*- # @Time : 2020/10/7 16:03 @Author : longrong.lang @FileName: test_tempdir.py @Software: PyCharm @Cnblogs :https://www.cnblogs.com/longronglang TestTempDir: def test_tempdir(self,tmpdir): print('n',tmpdir) 执行效果: 可以看到控制台有打印出生成的临时文件夹的目录,并且电脑本地也生成了文件夹! ? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |