pytest

Pytests on web.py application not covering methods code

帅比萌擦擦* 提交于 2020-03-22 09:27:30
问题 First of all, sorry if the linguo is not 100% correct or something does not make 100% of sense, I am quite new into web aplication development and posting on stack overflow in general. I have a web.py application and need to test its functionalities with pytest and generate a code coverage report with pytest-cov . I get the tests to work and assert on the responses, but when I generate the code report, all the lines of code inside the methods are uncovered and therefore get a really low test

pytest+allure+jenkins,生成allure报告

只谈情不闲聊 提交于 2020-03-17 16:28:01
1、本地生成allure报告 1、安装依赖 allure-2.13.2 allure-pytest-2.8.11 pytest-5.4.1 python-jenkins jdk-1.8 2、安装后验证安装是否成功 pip list 3、配置环境变量 jdk-1.8 pytest-5.4.1 allure-2.13.2 4、编写示例代码Demo import allure import pytest class Test_Pytest ( ) : @allure . feature ( "测试成功的用例" ) def test_one ( self ) : print ( "test_one方法执行" ) assert 1 == 1 @allure . feature ( "测试失败的用例" ) def test_two ( self ) : print ( "test_two方法执行" ) assert "s" in "love" @allure . feature ( "测试失败的用例" ) def test_three ( self ) : print ( "test_three方法执行" ) assert 3 - 2 != 1 @allure . feature ( "测试失败的用例" ) def test_four ( self ) : print ( "test

How to tell py.test to skip certain directories?

浪尽此生 提交于 2020-03-17 09:50:49
问题 I tried to use the norecursedirs option inside setup.cfg to tell py.test not to collect tests from certain directories but it seems it does ignore it. [tool:pytest] norecursedirs=lib/third When I run py.test I do see how it does get tests from inside lib/third ! 回答1: py.test --ignore=somedir worked for me 回答2: I solved the mystery: If a pytest section is found in one of the possible config files ( pytest.ini , tox.ini and setup.cfg ), pytest will not look for any others so be sure you define

How to tell py.test to skip certain directories?

混江龙づ霸主 提交于 2020-03-17 09:50:29
问题 I tried to use the norecursedirs option inside setup.cfg to tell py.test not to collect tests from certain directories but it seems it does ignore it. [tool:pytest] norecursedirs=lib/third When I run py.test I do see how it does get tests from inside lib/third ! 回答1: py.test --ignore=somedir worked for me 回答2: I solved the mystery: If a pytest section is found in one of the possible config files ( pytest.ini , tox.ini and setup.cfg ), pytest will not look for any others so be sure you define

How to tell py.test to skip certain directories?

淺唱寂寞╮ 提交于 2020-03-17 09:50:17
问题 I tried to use the norecursedirs option inside setup.cfg to tell py.test not to collect tests from certain directories but it seems it does ignore it. [tool:pytest] norecursedirs=lib/third When I run py.test I do see how it does get tests from inside lib/third ! 回答1: py.test --ignore=somedir worked for me 回答2: I solved the mystery: If a pytest section is found in one of the possible config files ( pytest.ini , tox.ini and setup.cfg ), pytest will not look for any others so be sure you define

Is there a way to control how pytest-xdist runs tests in parallel?

廉价感情. 提交于 2020-03-17 07:43:11
问题 I have the following directory layout: runner.py lib/ tests/ testsuite1/ testsuite1.py testsuite2/ testsuite2.py testsuite3/ testsuite3.py testsuite4/ testsuite4.py The format of testsuite*.py modules is as follows: import pytest class testsomething: def setup_class(self): ''' do some setup ''' # Do some setup stuff here def teardown_class(self): '''' do some teardown''' # Do some teardown stuff here def test1(self): # Do some test1 related stuff def test2(self): # Do some test2 related stuff

python学习-pytest(一)

馋奶兔 提交于 2020-03-16 08:56:19
学习pytest第一步 一、安装 pytest不是python默认的package,需要手动安装。 pytest支持python 2.6--3.5之间的版本,同时可以在windows、unix系统上安装 安装方式: pip install pytest 另外,可能会遇到一下问题: Could not find a version that satisfies the requirement pytest (from versions: ) No matching distribution found for pytest 解决办法:主要是国内网络问题,所以使用豆瓣源安装 pip install 包名 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com 示例:pip3 install pytest-html -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com 安装完成后,可以查看版本: pytest --version 参考文章: https://blog.csdn.net/yxxxiao/article/details/94591174 来源: https://www.cnblogs.com/zhaocbbb/p

allure标记用例级别severity

别来无恙 提交于 2020-03-15 20:49:17
转载至: https://www.cnblogs.com/yoyoketang/p/12194550.html 前言 我们在做功能测试的时候,执行完一轮测试用例,输出测试报告的时候,会有统计缺陷的数量和等级。 在做自动化测试的过程中,当你的测试用例越来越多的时候,如果执行一轮测试发现了几个测试不通过,我们也希望能快速统计出缺陷的等级。 pytest结合allure框架可以对用例的等级做详细的划分。 用例等级 allure对用例的等级划分成五个等级 blocker  阻塞缺陷(功能未实现,无法下一步) critical  严重缺陷(功能点缺失) normal   一般缺陷(边界情况,格式错误) minor  次要缺陷(界面错误与ui需求不符) trivial   轻微缺陷(必须项无提示,或者提示不规范) 比如我的用例有以下4条 那么对应的用例的等级应该是 修改个人信息-sex参数为空 这个属于边界值情况的测试,应该是normal级别 修改个人信息-sex参数传F和M两种类型,成功(枚举类型) 这个是针对接口的功能点详细测试 critical级别 修改个人信息-修改不是本人的用户信息,无权限操作 这个是针对接口的功能点详细测试 critical级别 修改个人信息-修改自己的个人信息,修改成功 这是用例是测试主流程 blocker级别 pytest用例

蟒周刊-411-2020 应该如何享用 Jupyter?

浪子不回头ぞ 提交于 2020-03-12 21:18:46
原文: PyCoder's Weekly - Issue #411 200311 Zoom.Quiet (大妈) 用时 42 分钟 完成快译 200311 Zoom.Quiet (大妈) 用时 17 分钟 完成格式转抄. Post-Mortem Python 绘图 ANDY JONES Who loves debugging things that only fail occasionally? Just me? Maybe you need to check out Andy Jones’ extract() function that “magically” extracts a caller’s environment into an IPython interpreter session. Mix in a little post-mortem debugging with Jupyter’s %debug magic command, and you’ll be painlessly debugging finicky code in no time. ( 是也乎: 神奇的事后验尸, extract() 能将调用者环境装配人 Jupyter 进行细致的检验. ) 2020 年如何用 Jupyter 笔记本 LJ MIRANDA In this first of a

pytest跳过执行skip和skipif

拈花ヽ惹草 提交于 2020-03-10 09:33:01
相关函数 pytest.mark.skip pytest.mark.skipif 可以看看原函数 @staticmethod def skipif(condition, reason=None): """skip the given test function if eval(condition) results in a True value. Optionally specify a reason for better reporting. Evaluation happens within the module global context. Example: ``skipif('sys.platform == "win32"')`` skips the test if we are on the win32 platform. see http://doc.pytest.org/en/latest/skipping.html """ @staticmethod def skip(reason=None): """skip the given test function, optionally specify a reason for better reporting. see http://doc.pytest.org/en/latest/skipping.html """