可以把多个test放在一个class里,

class TestClass(object):

    def test_one(self):
x = "this"
assert 'h' in x def test_two(self):
x = "hello"
assert hasattr(x, 'check')

  

为什么会找到呢,因为,在pytest的文档里,说明查找的规范思路:

pytest implements the following standard test discovery:

  • If no arguments are specified then collection starts from testpaths (if configured) or the current directory. Alternatively, command line arguments can be used in any combination of directories, file names or node ids.
  • Recurse into directories, unless they match norecursedirs.
  • In those directories, search for test_*.py or *_test.py files, imported by their test package name.
  • From those files, collect test items:
    • test_ prefixed test functions or methods outside of class
    • test_ prefixed test functions or methods inside Test prefixed test classes (without an __init__ method)

For examples of how to customize your test discovery Changing standard (Python) test discovery.

Within Python modules, pytest also discovers tests using the standard unittest.TestCasesubclassing technique.

这里需要注意的是,这个类不能有__init__

最新文章

  1. Linux C++线程池
  2. xml报文的装配解析
  3. 最大化 AIX 上的 Java 性能,第 2 部分: 速度需求
  4. android下拉菜单 spinner 学习
  5. java -X 这不是标准的选项只是为了获取帮助信息
  6. Engine许可初始化 - gis开发初步
  7. zend studio 函数不提醒 小黄图标 小黄标
  8. iOS判断字符串是否包含表情字符
  9. [转载]Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
  10. 基于Quartz.NET框架的WinForm任务计划管理工具
  11. Android简易实战教程--第三十九话《Chronometer实现倒计时》
  12. 英语口语练习系列-C03-常用问句
  13. Nginx入门基础(一)
  14. VMware安装操作系统提示 " Intel VT-x 处于禁用状态"解决方法
  15. 解决每次调试网页,eclipse总是提示edit source lookup path的问题,我的第一篇小随笔,小激动呢
  16. vue中的页面渲染方案
  17. mybatis中批量更新的问题
  18. HelloStruts
  19. Caffe训练AlexNet网络模型——问题三
  20. ACdream原创群赛__15

热门文章

  1. Linux 监测系统资源
  2. 项目常用解决方案之SystemSetting.xml文件的修改与读取
  3. hw_breakpoint使用方法
  4. [剑指Offer] 36.两个链表的第一个公共结点
  5. Delphi xe7组件和控件的安装方法
  6. hihoCoder #1872 : Pythagorean triple
  7. 【题解】NOI2009管道取珠
  8. 【题解】SDOI2008莎拉公主的困惑
  9. NOIP2010 codevs1069 洛谷P1525 关押罪犯
  10. 线程--promise furture 同步