zoukankan      html  css  js  c++  java
  • pytest学习(3)

    在pytest 2.0以上的版本里,我们也可以通过python -m pytest ...来调用。这实际上和pytest 。。。几乎一摸一样。

    只是用python的时候,把当面目录也加入到sys.path中。

    pytest的返回值如下:

    Exit code 0:	All tests were collected and passed successfully
    Exit code 1:	Tests were collected and run but some of the tests failed
    Exit code 2:	Test execution was interrupted by the user
    Exit code 3:	Internal error happened while executing tests
    Exit code 4:	pytest command line usage error
    Exit code 5:	No tests were collected
    

     

    pytest的一些常用的命令你:

    pytest --version 显示pytest import的版本,以及已经注册的插件。

    C:fitmehttpie	ests>pytest --version
    This is pytest version 3.1.3, imported from c:python35libsite-packagespytest.py
    setuptools registered plugins:
      pytest-httpbin-0.2.3 at c:python35libsite-packagespytest_httpbinplugin.py
    

      pytest 碰到第几个错误停止:

    pytest -x            # stop after first failure
    pytest --maxfail=2    # stop after two failures
    

      指定路径啊,文件啊,文件里的函数,类等进行测试。

    pytest test_mod.py   # run tests in module
    pytest somepath      # run all tests below somepath
    pytest -k stringexpr # only run tests with names that match the
                          # "string expression", e.g. "MyClass and not method"
                          # will select TestMyClass.test_something
                          # but not TestMyClass.test_method_simple
    pytest test_mod.py::test_func  # only run tests that match the "node ID",
                                    # e.g. "test_mod.py::test_func" will select
                                    # only test_func in test_mod.py
    pytest test_mod.py::TestClass::test_method  # run a single method in
                                                 # a single class
    

      

  • 相关阅读:
    git push :推送本地更改到远程仓库的三种模式
    GIT版本库回滚【图文版】
    微服务架构的分布式事务解决方案
    断路器-Hystrix的深入了解
    Elasticsearch顶尖高手系列课程推荐
    Dockerfile分离构建LNMP环境部署wordpress
    ELK 聚合查询
    tomcat日志采集
    ELK采集之nginx 之高德地图出城市IP分布图
    Elasticsearch 安装与集群配置
  • 原文地址:https://www.cnblogs.com/aomi/p/7216186.html
Copyright © 2011-2022 走看看