Saravanan666/pypi-org huggingface dataset:
Package: pytest-reorder
Reorder tests depending on their nodeids (strings of test file path plus test name plus
parametrization, like:test/test_prefix_reordering.py::test_reordering_default[test_names5-expected_test_order5]).Normally tests are sorted alphabetically. That makes integration tests run before unit tests.Withpytest_reorderyou can install a hook that will change the order of tests in the suite.
By defaultpytest_reorderwill seek forunit,integrationanduitests and put them in
the following order:unitall tests with names not indicating unit, integration, nor UI testsintegrationuiThe default regular expressions can find unit, integration and UI tests both laid flat anddeeply
nested. You can also specify your custom order.HOWTOIt’s possible to customize the ordering. To do so, you have to specify your custom tests order
by passing a list of regular expresions that match tests’ nodeids. If more than one regex matches
some test nodeid, the first one wins.Command line interfacepytest_reorderhooks in a--reordercommand line option that takes zero arguments or an
ordering spec list.If no arguments are given, default reordering will be applied.If a list is passed, e.g.--reorder'(^|.*/)(test_)?unit''*''(^|.*/)(test_)?web', tests
are reordered to go as the matches in the list do. Regular list items are treated as Python
regexes. The special'*'match is required and specifies where to put tests that don’t
match any of the regexes. A single asterisk was chosen for that because it’s not a valid regular
expression.Programmatic interfaceModify your main conftest file (e.g.tests/conftest.py) to include:frompytest_reorderimportdefault_reordering_hookaspytest_collection_modifyitems# add noqa here if you use pyflakesor specify a custom test order:frompytest_reorderimportmake_reordering_hook# Make unit tests run before 'db' tests, which run before 'web' tests. Other tests will run at# the very beginning of the suite:pytest_collection_modifyitems=make_reordering_hook([None,r'(^|.*/)(test_)?unit',r'(^|.*/)(test_)?db',r'(^|.*/)(test_)?web'])Without pytest_reorderFlat:sample_test_suites/flat/test_sample.py ...
sample_test_suites/flat/integration/test_some_integration.py ..
sample_test_suites/flat/ui/test_some_ui.py .
sample_test_suites/flat/unit/test_some_unit.py ..Nested:sample_test_suites/nested/app_1/tests/integration/test_some_integration.py ..
sample_test_suites/nested/app_1/tests/ui/test_some_ui.py .
sample_test_suites/nested/app_1/tests/unit/test_some_unit.py ..
sample_test_suites/nested/app_2/tests/test_sth.py ...
sample_test_suites/nested/app_2/tests/test_unit.py .With pytest_reorderFlat:sample_test_suites/flat/unit/test_some_unit.py ..
sample_test_suites/flat/test_sample.py ...
sample_test_suites/flat/integration/test_some_integration.py ..
sample_test_suites/flat/ui/test_some_ui.py .Nested:sample_test_suites/nested/app_1/tests/unit/test_some_unit.py ..
sample_test_suites/nested/app_2/tests/test_unit.py .
sample_test_suites/nested/app_2/tests/test_sth.py ...
sample_test_suites/nested/app_1/tests/integration/test_some_integration.py ..
sample_test_suites/nested/app_1/tests/ui/test_some_ui.py .
Package: pytest-repeat
pytest-repeat is a plugin forpytestthat makes it
easy to repeat a single test, or multiple tests, a specific number of times.RequirementsYou will need the following prerequisites in order to use pytest-repeat:Python 3.7+ or PyPy3pytest 4 or newerInstallationTo install pytest-repeat:$pipinstallpytest-repeatRepeating a testUse the--countcommand line option to specify how many times you want
your test, or tests, to be run:$pytest--count=10test_file.pyEach test collected by pytest will be runcounttimes.If you want to mark a test in your code to be repeated a number of times, you
can use the@pytest.mark.repeat(count)decorator:importpytest@pytest.mark.repeat(3)deftest_repeat_decorator():passIf you want to override default tests executions order, you can use--repeat-scopecommand line option with one of the next values:session,module,classorfunction(default).
It behaves like a scope of the pytest fixture.function(default) scope repeats each testcountorrepeattimes before executing next test.sessionscope repeats whole tests session, i.e. all collected tests executed once, then all such tests executed again and etc.classandmodulebehaves similarsession, but repeating set of tests is a tests from class or module, not all collected tests.Repeating a test until failureIf you are trying to diagnose an intermittent failure, it can be useful to run the same
test over and over again until it fails. You can use pytest’s-xoption in
conjunction with pytest-repeat to force the test runner to stop at the first failure.
For example:$pytest--count=1000-xtest_file.pyThis will attempt to run test_file.py 1000 times, but will stop as soon as a failure
occurs.UnitTest Style TestsUnfortunately pytest-repeat is not able to work with unittest.TestCase test classes.
These tests will simply always run once, regardless of--count, and show a warning.ResourcesRelease NotesIssue TrackerCode
Package: pytest_repeater
pytest_repeaterWarningThis pytest plugin’s development, has been stopped.
Please usepytest-repeatinstead.HistoryThis package was created based onthread from StackOverflowabout repeating py.test tests.Use caseTrack down heisenbug infoo_testby running it 50 times:py.test -k foo_test --repeat 50Package resourcesBug tracker:https://github.com/ClearcodeHQ/pytest-repeater/issuesTravis-ciAfter creating package on github, move to tracis-ci.org, and turn on ci builds for given package.CHANGELOG0.1.1pacakge deprecation0.1.0base code and tests
Package: pytest-report
converts pytest output to atom’s linter messageThisPytestplugin was generated withCookiecutteralong with@hackebrot’sCookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-report” viapipfromPyPI:$ pip install pytest-reportUsageTODOContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theMITlicense, “pytest-report” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-reporter
GeneratePytestreports from templates. You may use one of the available
templates on PyPI (like the reference templatepytest-reporter-html1),
inherit them in your own template to tweak their content and appearence or
make your own from scratch.Anything text based can be generated like HTML, LaTeX, CSV et.c.InstallationYou can install “pytest-reporter” viapipfromPyPI:$ pip install pytest-reporterUsageSpecify the template you want to use and the output path of the report:$ pytest --template-dir=templates --template=report.html --report=report.htmlWriting templatesThis plugin does not come with built-in support for any template engines,
it is up to each template to implement the rendering (or use another template
plugin as base). A minimal template may just implement thepytest_reporter_renderhook.This is a very basic Jinja2 template implementation:fromjinja2importEnvironment,FileSystemLoader,TemplateNotFounddefpytest_reporter_render(template_name,dirs,context):env=Environment(loader=FileSystemLoader(dirs))try:template=env.get_template(template_name)exceptTemplateNotFound:# Don't know about this name, may be provided by some other templatereturnreturntemplate.render(context)Seepytest-reporter-html1for a full reference implementation.The template contextThe standard context available for all templates include the following:config:Configsession:Sessionstarted: Unix timestamp when session startedended: Unix timestamp when session was finishedwarnings[]: List of warnings.WarningMessageitems: Dictionary of collected items with nodeid as keystests[]: List of each test run as dictionaries with the following keys:item:Itemphases[]: List of each test phase (setup, call, teardown) as dictionaries
with the following keys:call(optional):CallInfoif available.report:TestReportsections: Same asreport.sectionsbut only the sections captured for this phaselog_records[]: List oflogging.LogRecordrecorded during the test phasestatus: Status of this phase. Dictionary with the following keys:category: Category of the status (e.g."passed") or empty stringletter: Single letter version of status (e.g."P") or empty stringword: Uppercase word version of status (e.g."PASSED") or empty stringstyle: Dictionary with e.g.{"yellow": True}or empty dictionarystatus: Status of whole test. Dictionary with the following keys:category: Category of the test status (e.g."passed")letter: Single letter version of test status (e.g."P")word: Uppercase word version of test status (e.g."PASSED")style: Dictionary with e.g.{"yellow": True}or empty dictionaryThe context may be extended or modified using the following methods:config.template_contextThetemplate_contextfixtureThepytest_reporter_context()hookHooksSeehooks.pyfor a complete list of hooks available.LicenseDistributed under the terms of theMITlicense, “pytest-reporter” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-reporter-html1
A basic HTML report forpytestusingJinja2template engine.
Based onpytest-reporterwhich provides the data to the template.FeaturesOverview of files, tests, and phases with expandable sectionsIncludes information about tests such as documentation, markers, and fixturesFairly mobile friendlyComplies with Jenkins default CSP policy (with--split-report)Support forpytest-metadataandpytest-rerunfailuresMay be used as a base template for customizationInstallationYou can install “pytest-reporter-html1” viapipfromPyPI:$ pip install pytest-reporter-html1UsageSpecify the html1 template and the output path of the report:$ pytest --template=html1/index.html --report=report.htmlBy default the report is self-contained, but you can separate CSS, images,
and JavaScript by specifying the--split-reportoption.CustomizationYou can inherit this template in your own to tailor parts of it to your own needs.
It defines various blocks which you can override usingtemplate inheritance.{% extends "html1/index.html" %}
{% block style %}
    {{ super() }}
    header {
        background-color: black;
    }
{% endblock %}Some additional filters are available for templates to use:asset(path_or_content, extension)Takes a path to a local file or a raw bytes object and either returns a
base64 encoded URL or a new relative URL to a copy depending on if the
report is self-contained or not.<imgsrc="{{ 'path/to/image.png'|asset }}"><imgsrc="{{ raw_byte_data|asset('png') }}">ansi(s)Convert ANSI color codes to HTML.strftime(value, format)Format a Unix timestamp usingdatetime.strftime.Started: {{ started|strftime('%Y-%m-%d %H:%M:%S') }}timedelta(value)Convert a time in seconds to atimedeltaobject.rst(s)Convert reStructuredText to HTML.IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-reporter-html-dots
This is a fork of the great templatepytest-reporter-html1with one detail changed: Instead of grouping the tests and showing only a number how many tests have failed and how many have passed, this template tries to mimic the standard pytest output with one dot for every test.
This has the advantages that (1) even without expanding a file it’s visible which tests have failed and whether they are the same like in the last run and (2) it gives a better visualization how many tests have failed in a specific file.
Hovering over a badge shows the name of the test and it’s status (e.g. passed/failed/skipped).A basic HTML report forpytestusingJinja2template engine.
Based onpytest-reporterwhich provides the data to the template.FeaturesOverview of files, tests, and phases with expandable sectionsIncludes information about tests such as documentation, markers, and fixturesFairly mobile friendlyComplies with Jenkins default CSP policy (with--split-report)Support forpytest-metadataandpytest-rerunfailuresMay be used as a base template for customizationInstallationYou can install “pytest-reporter-html-dots” viapipfromPyPI:$ pip install pytest-reporter-html-dotsUsageSpecify the html-dots template and the output path of the report:$ pytest --template=html-dots/index.html --report=report.htmlBy default the report is self-contained, but you can separate CSS, images,
and JavaScript by specifying the--split-reportoption.CustomizationYou can customize this template usingtemplate inheritance.If you want to add more information to the meta data table, extend thesession_metadatablock.
Create the following file calledreport-template.htmlnext to yourtox.ini:{% extends "html-dots/index.html" %}
{% block session_metadata %}
    {{ super() }}<tr><th>System under test version</th><td>{{ version }}</td></tr>{% endblock %}Addversionto the context in thepytest_reporter_context hookinconftest.py:importpytest@pytest.hookimpl# type: ignore [misc]  # Untyped decorator makes function "pytest_reporter_context" untypeddefpytest_reporter_context(context:'dict[str, object]',config:'pytest.Config')->None:context['version']='0.1.2'Add--template-dirand change--templateintox.ini(I am usingbashto insert a timestamp into the report name via command substitution withdate):[tox]envlist=py3isolated_build=True[testenv]allowlist_externals=bashdeps=mypypytestpytest-reporter-html-dotscommands=mypy srcbash -c "pytest --template-dir={toxinidir} --template=report-template.html --report={toxinidir}{/}log{/}pytest-`date +%Y-%m-%d_%H-%M`.html {posargs}"Some additional filters are available for templates to use:asset(path_or_content, extension)Takes a path to a local file or a raw bytes object and either returns a
base64 encoded URL or a new relative URL to a copy depending on if the
report is self-contained or not.<imgsrc="{{ 'path/to/image.png'|asset }}"><imgsrc="{{ raw_byte_data|asset('png') }}">ansi(s)Convert ANSI color codes to HTML.strftime(value, format)Format a Unix timestamp usingdatetime.strftime.Started: {{ started|strftime('%Y-%m-%d %H:%M:%S') }}timedelta(value)Convert a time in seconds to atimedeltaobject.rst(s)Convert reStructuredText to HTML.
Package: pytest-reporting
A plugin to report summarized results in a table formatThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-reporting” viapipfromPyPI:$ pip install pytest-reportingUsageTODOContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theMITlicense, “pytest-reporting” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-reportportal
Pytest plugin for reporting test results of the Pytest to the ReportPortal.InstallationTo install pytest plugin execute next command in a terminal:pipinstallpytest-reportportalLook through the CONTRIBUTING.rst for contribution guidelines.ConfigurationPrepare the config filepytest.iniin root directory of tests or specify
any one using pytest command line option:py.test-cconfig.cfgThepytest.inifile should have next mandatory fields:rp_api_key- value could be found in the User Profile sectionrp_project- name of project in ReportPortalrp_endpoint- address of ReportPortal ServerExample ofpytest.ini:[pytest]
rp_api_key = fb586627-32be-47dd-93c1-678873458a5f
rp_endpoint = http://192.168.1.10:8080
rp_project = user_personal
rp_launch = AnyLaunchName
rp_launch_attributes = 'PyTest' 'Smoke'
rp_launch_description = 'Smoke test'
rp_ignore_attributes = 'xfail' 'usefixture'Therp_api_keycan also be set with the environment variableRP_API_KEY. This will override the value set forrp_api_keyin pytest.iniThere are also optional parameters:https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/ExamplesFor logging of the test item flow to ReportPortal, please, use the python
logging handler provided by plugin like bellow:in conftest.py:importloggingimportsysimportpytestfromreportportal_clientimportRPLogger@pytest.fixture(scope="session")defrp_logger():logger=logging.getLogger(__name__)logger.setLevel(logging.DEBUG)logging.setLoggerClass(RPLogger)returnloggerin tests:# In this case only INFO messages will be sent to the ReportPortal.deftest_one(rp_logger):rp_logger.info("Case1. Step1")x="this"rp_logger.info("x is:%s",x)assert'h'inx# Message with an attachment.importsubprocessfree_memory=subprocess.check_output("free -h".split())rp_logger.info("Case1. Memory consumption",attachment={"name":"free_memory.txt","data":free_memory,"mime":"application/octet-stream",},)# This debug message will not be sent to the ReportPortal.rp_logger.debug("Case1. Debug message")LaunchingTo run test with ReportPortal you must provide ‘–reportportal’ flag:py.test./tests--reportportalCheck the documentation to find more detailed information about how to integrate pytest with ReportPortal using an agent:https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/Copyright NoticeLicensed under theApache 2.0license (see the LICENSE file).
Package: pytest-requests
A simple plugin to use with pytestThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-requests” viapipfromPyPI:$ pip install pytest-requestsUsageTODOContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theMITlicense, “pytest-requests” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-requestselapsed
pytest-requestselapsed当前插件对requests库进行简单的封装使它成为一个fixture对象.安装插件pip3installpytest-requestselapsed测试用例test_case.py不需要导入 requests 库, 在测试函数入口声明使用 requests Fixture就具备使用 requests 库的能力.deftest_baidu(requests):resp=requests.get("https://www.baidu.com")assertresp.status_code<400deftest_qq(requests):resp=requests.get("https://weixin.qq.com/")assertresp.status_code<400deftest_taobao(requests):resp=requests.get("https://www.taobao.com")assertresp.status_code<400deftest_bilibili(requests):resp=requests.get("https://www.bilibili.com")assertresp.status_code<400测试报告默认表现$cdexample/readme/
$pytest=======================================testsessionstarts=======================================platformlinux--Python3.8.10,pytest-7.1.2,pluggy-1.0.0
rootdir:/home/zt/PycharmProjects/pytest-requestselapsed/example/readme
plugins:requestselapsed-0.0.1
collected4itemstest_case.py....[100%]========================================4passedin1.44s========================================在控制台打印api响应报告$cdexample/readme/
$pytest--output-mode=console=============================================testsessionstarts=============================================platformlinux--Python3.8.10,pytest-7.1.2,pluggy-1.0.0
rootdir:/home/zt/PycharmProjects/pytest-requestselapsed/example/readme
plugins:requestselapsed-0.0.1
collected4itemstest_case.py....[100%]elapsedmethodurl0.690789GEThttps://www.bilibili.com/?rt=V%2FymTlOu4ow%2Fy4xxNWPUZxCA8HpNf6nrCC8%2BjIwXT0M%3D0.572896GEThttps://www.bilibili.com/0.498390GEThttps://www.baidu.com/0.387840GEThttps://weixin.qq.com/0.159209GEThttps://www.taobao.com/==============================================4passedin1.58s==============================================在飞书群聊窗口打印api响应报告$ cd example/readme/
  $ pytest --output-mode=feishu --feishu-webhook-url=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  ======================================= test session starts =======================================
  platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0
  rootdir: /home/zt/PycharmProjects/pytest-requestselapsed/example/readme
  plugins: requestselapsed-0.0.1
  collected 4 items                                                                                                      
  
  test_case.py ....                                                                            [100%]
  
  ======================================== 4 passed in 1.44s ========================================更多案例参考这里
Package: pytest-requests-futures
MOCKING REQUESTS FUTURESPytest Plugin to Mock Requests FuturesCode:https://github.com/boromir674/pytest-requests-futuresDocs:https://pytest-requests-futures.readthedocs.io/en/master/PyPI:https://pypi.org/project/pytest-requests-futures/CI:https://github.com/boromir674/pytest-requests-futures/actions/Featurespytest_requests_futurespython packageTODO Document aGreat FeatureTODO Document anotherNice FeatureTested against multipleplatformsandpythonversionsDevelopmentHere are some useful notes related to doing development on this project.Test Suite, usingpytest, located intestsdirParallel Executionof Unit Tests, on multiple cpu’sDocumentation Pages, hosted onreadthedocsserver, located indocsdirAutomation, usingtox, driven by singletox.inifileCode CoveragemeasuringBuild Command, using thebuildpython packagePypi Deploy Command, supporting upload to bothpypi.organdtest.pypi.orgserversType Check Command, usingmypyLintCheckandApplycommands, usingisortandblackCI Pipeline, running onGithub Actions, defined in.github/Job Matrix, spanning differentplatform’s andpython version’sPlatforms:ubuntu-latest,macos-latestPython Interpreters:3.6,3.7,3.8,3.9,3.10Parallel Jobexecution, generated from thematrix, that runs theTest SuitePrerequisitesYou need to havePythoninstalled.QuickstartUsingpipis the approved way for installingpytest_requests_futures.python3-mpipinstallpytest_requests_futuresTODO Document a use caseLicenseGNU Affero General Public License v3.0LicenseFree software: GNU Affero General Public License v3.0
Package: pytest-requires
pytest-requiresA pytest plugin to elegantly skip tests with optional requirementsThispytestplugin was generated
withCookiecutteralong with@hackebrot'scookiecutter-pytest-plugintemplate.Featuresdecorate tests that require optional modules (with an optional minimum version)
and gracefully skip them when the requirements aren't importableRequirementspytestInstallationYou can install "pytest-requires" viapipfromPyPI:pipinstallpytest-requiresUsageHow to use pytest-requiresWith pytest-requires, tests can be marked as requiring an external module
as follows:@pytest.mark.requires("dateutil")deftest_date_parsing():assertdate_parsing()==RESULTIn this example if the python-dateutil module isn't installed the test is
skipped.
The import testing is all performed by pytest's builtinimportorskipfunction.Notes:theminversionkeyword can be given to specifiy a minimum acceptable
version for the required modulemultiple modules can be given as positional arguments, with the decorated
tested being skipped if any of the given modules cannot be importedin the case of multiple modules, only a singleminversioncan be given,
and will be used for all modules; if an independentminversionis required
for each module, use multiple@pytest.mark.requiresdecorators.Why not just usepytest.importorskip?pytest.importorskipis designed to import a module and add the module
to the namespace (of the module, or the test function).
If the optional module isn't used in the test itself, but is really a
requirement of the functionbeing tested, the call toimportorskipless elegant (in the author's opinion) than a decorator call.ContributingContributions are very welcome, please open a Pull Request.LicenseDistributed under the terms of theMITlicense, "pytest-requires"
is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.