安装pytest 1.在命令行中运行以下命令: pip install -U pytest 2.检查已经安装的版本: pytest --version This is pytest version 3.7.2, imported from c:\python27\lib\site-packages\pytest.pyc 创建第一个测试用例 使用四行代码创建一个简单的测试函数: # content of test_sample.py def func(x): return x + 1 def te
继续pytest单元测试框架的学习,pytest可以生成多种类型的测试报告.这一节就来学习pytest如何生成测试报告. 创建test_calss.py 测试用例文件,这里以测试该文件为例. #coding=utf-8 class TestClass: def test_one(self): x = "this" assert "h" in x def test_two(self): x = "hello" assert x == "h