Saravanan666/pypi-org huggingface dataset:
Package: pytest-android
pytest-androidpytest-android is a plugin forpytestthat provides a configured 'driver' for Android Automated Testing, usinguiautomator2.pytest-android 是pytest的插件，它通过uiautomator2为 Android 自动化测试提供“驱动”。目录pytest-android目录主要功能安装1. 安装 python2. 创建工程3. 安装插件和一些可选模块使用1. 创建配置文件1.1 创建配置文件 config.yaml 和 pytest.ini1.2 根据需求调整配置[可选]2. 编写用例2.1 可用的Fixtures2.2 编写用例IssuesLicense主要功能整合uiautomator2，实现基于控件的自动化测试依赖pytest-variables实现参数化配置借助allure生成测试报告借助 hook 机制，实现“点击、滑动时自动截图”、“异常时自动抓取控件信息和截图”等 fixture，减少重复工作通过安装 pytest 插件，实现诸如“失败重试”、“分布式执行”、“用例分层”等安装强烈建议使用 git 对代码进行版本控制，灵活运用分支开发的策略，并且将自动化整合进 DevOps 流程中。推荐本地开发使用基于virtualenv的工具实现环境隔离和解决各个模块之间的依赖，如pipenv。建议生产环境使用docker对各个设备之间进行“隔离”。1. 安装 pythonmacOS、linux可以通过pyenv实现多个 python 版本的共存和切换，Windows上需要下载可执行文件、手动安装和配置环境变量。因为使用了 python 3.6 的f-string特性，所以建议的 python 版本大于等于3.6。具体安装过程略。2. 创建工程mkdirdemocddemo3. 安装插件和一些可选模块推荐使用pipenv进行环境管理：# macOSbrewinstallpipenv# windows,linuxpipinstall--userpipenv# 必须，根据您的配置文件格式，二选一（因为插件目前在 alpha 测试阶段，需要添加`--pre`参数）# 注意，pipenv在2018.11.26版本之后，才能支持额外（extras）模块（即安装时的中括号语法），所以使用较新的版本、或手动安装pipenvinstall--prepytest-android[yaml]# yaml 作为配置文件，推荐pipenvinstall--prepytest-android[hjson]# json 作为配置文件# 以下为可选模块，根据需要选择性安装pipenvinstallweditor# uiautomator2 的录制工具pipenvinstallallure-pytest# 使用 allure 生成报告pipenvinstallpytest-rerunfailures# 使 pytest 支持失败重试PS: pip版本大于等于18时，pipenv需要的最低版本为2018.11.26（如果低于此版本会导致一系列错误）注意：根据这里的观点，pytest-android 作为libraries，将部署到某个特定的环境中，然后才能使所有依赖项和子依赖项的确切版本具体化。使用1. 创建配置文件1.1 config.yaml创建项目级配置文件，参考config.yaml。此文件可以使用 yaml 和 hjson 格式（由 pytest-variables 插件实现），文件名任意。配置文件可以同时指定多个（遇到相同字段，后面的会覆盖前面的），借助此功能可以实现：指定设备参数、实现复杂情况下的兼容性测试等。1.2 pytest.ini创建 pytest 的配置文件，参考文档进行基础配置。添加addopts = --variables config.yaml，指定项目配置文件。1.1 创建配置文件 config.yaml 和 pytest.ini项目配置文件 config.yaml，pytest 配置文件 pytest.ini ，区别：pytest.ini 只能有一个，且文件名不可修改；config.yaml 可以有多个（通过 pytest-variables 插件实现，需在pytest.ini 中指定），文件名任意，并且可以同时载入多个文件（遇到重复字段时，最后一个生效）。通过配置文件，可以对测试进行参数化配置，提高测试的灵活性，降低代码维护的工作量，和减少可能的疏忽导致的异常。目前已实现命令行工具，可以直接执行命令下载对应的配置文件示例：pipenvrunpython-mpytest_androiddownload--init如果已经手动创建，或者想重新下载指定的文件，可以附加对应的参数：pipenvrunpython-mpytest_androiddownload--pytest.ini
pipenvrunpython-mpytest_androiddownload--config.yaml当本地文件与示例文件不一致时，会提示是否覆盖，可以选择N然后手动合并。1.2 根据需求调整配置[可选]如果使用 allure 生成报告，并安装了对应依赖，可以通过--alluredir指定报告的路径，通过--clean-alluredir指定开始前是否清理历史数据。更多参数可参考插件文档如果借助 pytest-rerunfailures 插件实现失败重试，参考插件文档，添加--reruns其他诸如 log 、markers，和第三方插件配置，根据需要参考对应文档。2. 编写用例2.1 可用的Fixtures此处文档可能更新不及时，通过执行命令python -m pytest --fixtures，可以列出所有 fixtures 及其最新说明文档。NameScopeAutouseDescriptiondriversessionTrue初始化设备show_case_namefunctionTruetoast 提示显示用例描述或名字，便于了解进度app_startfunctionTrue启动 app ，（仅）通过当前 app 包名判断是否启动根据 pytest 的加载顺序，插件中定义的 fixture 是可以被conftest.py和本地插件pytest_plugins覆盖的。也就是说，如果具体到项目时不满足需求，可以在工程内新建conftest.py文件，编写同名 fixture，修改scope、autoues和其具体行为。2.2 编写用例新建文件test_demo.py，输入以下代码：#!/usr/bin/env python# encoding: utf-8fromuiautomator2importUIAutomatorServerdeftest_233(driver:UIAutomatorServer):print(driver.device_info)运行：pipenvrunpython-mpytestIssues如果插件使用中遇到问题，请通过github issues提交。LicenseDistributed under the terms of theMITlicense, "pytest-android" is free and open source software.根据MIT许可条款分发，“pytest-android”是免费的开源软件。
Package: pytest-ansible-units
pytest-ansible-unitsAn experimentalpytestplugin to run an ansible collection's unit tests withpytest.Descriptionpytest-ansible-unitsis apytestplugin that allows an ansible collection's unit tests to be run with onlypytest.pytestcan be used from the command line or from the IDE.Getting StartedDependenciesInstallingpytest-ansible-unitswill install the following:pytestpytest-ansible-unitsrequires python 3.8 or greater, ansible-core and pyyaml.Installingpython -m pip install pytest-ansible-unitsansible-coreandpyyamlneed to be installed to activate the plugin.2 directory structures are supported, with either approach collection dependencies need to be installed. Either in the default user location or in the collection tree structure in option 1.Collection treeThe preferred approach is to clone the collections being developed into it's proper collection tree path. This eliminates the need for any symlinks and other collections being developed can be cloned into the same tree structure.git clone <repo> collections/ansible_collections/<namespace>/<name>Note:pytestneeds to be run in the root of the collection directory, adjacent to the collection's galaxy.yml fileShallow treeThe alternative approach allow for a shallow directory structure.git clone <repo>Notes:pytestneeds to be run in the root of the collection directory, adjacent to the collection's galaxy.yml fileA collections directory will be created in the repository directory and the collections content linked into it.Add/collections/to the .gitignore, since there is no need for this to be checked in.ansible-test sanitywill fail due to the symlinks, with this approach.Executing programFrom the command line, from the collection's root directory:pytest testsHelpThe following may be added to the collections'pyproject.tomlfile to limit warnings and set the default path for the collection's tests[tool.pytest.ini_options]
testpaths = [
    "tests",
]
filterwarnings = [
    'ignore:AnsibleCollectionFinder has already been configured',
]Information from thegalaxy.ymlfile is used to build thecollectionsdirectory structure and link the contents. Thegalaxy.ymlfile should reflect the correct collection namespace and name.One way to detect issues without running the tests is to run:pytest --collect-onlyThe follow errors may be seen:E   ModuleNotFoundError: No module named 'ansible_collections'Check thegalaxy.ymlfile for an accurate namespace and nameEnsurepytestis being run from the collection's root directory, adjacent to thegalaxy.ymlHINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modulesEnsure each test directory has an__init__.pyAuthorscidrblockLicenseThis project is licensed under the GPL-v3 License - see the LICENSE file for details
Package: pytest-antilru
pytest-antilruCaching expensive function calls withfunctools.lru_cacheis simple and great performance optimization.
It works so well that it'll even speed up your unit test runs!
Too bad it violated test isolation and caches the wrong values under test conditions, introducing test pollution
(persisted state between test runs).
This package will bust thelru_cachebetween test runs, avoiding test pollution and helping you keep your sanity.Imagine you mock a network call out and your application ends up caching these mocked results:defexpensive_network_call()->int:# Pretend this is an expensive network call.# You want to cache this for performance but you want to run tests with different responses as well.return1@lru_cache()defcache_me()->int:returnexpensive_network_call()Now you have test pollution:deftest_a_run_first()->None:assertcache_me()==1deftest_b_run_second()->None:# We want to mock the network call for this test casewithmock.patch.object(sys.modules[__name__],'expensive_network_call',return_value=2)asmock_network_call:assertcache_me()==2assertmock_network_call.calledOn your next test run, it doesn't matter what you
mock, the results are already cached. Now trying running those two test out-of-order sequence and tell me how it goes.DependenciesSince this is apytestplugin, you need to be usingpytestto run your tests.CompatibilityThis project is python 2.7 and python 3.5+ compatible.
It is compatible with pytest 2+.
While we aim to support a wide range of python and pytest combinations, pytest only supports the latest release:
they do not patch older releases to work with newer python versions.
See [tox.ini] for the full envlist of what is being tested.If you experience issues, please check for compatibility between your python and pytest target versions.
Open an issue once these are verified.InstallationSimply install this in the same python environment thatpytestuses and the rest is magic.pipinstallpytest-antilruHow to test the softwaremaketestCredits and referencesThis project was a re-engineering of a similar project a colleague of mine wrote.
That project was not intended to be open-source and rather than go though all the hoops and hurdles to sanitize it,
I've written it from the ground up such that it's kosher to open-source (given that it's such as small project).
Package: pytest-anything
If you ever had to ignore a certain part of an assertion, you would end up with
this.importpytest@pytest.mark.parametrize("obj",["string",123,123.1,True,False,[],{},(),object,object(),type,type(None),None,],)deftest_anything(obj,Anything):assertobj==Anything@pytest.mark.parametrize("obj",["string",123,123.1,True,False,[],{},(),object,object(),type,type(None),],)deftest_something(obj,Something):assertobj==Somethingdeftest_nothing(Something):assertNone!=Somethingdeftest_something_special(Something):assertobject()==Something(lambdax:isinstance(x,object))
Package: pytest-api
PyTest-API: Populate OpenAPI Examples from Python TestsPyTest-API is anASGI middlewarethat populatesOpenAPI-Specificationexamples frompytestfunctions.Installationpoetry add --dev pytest-apiHow to use it:Starting withtest_main.pyfile:from.mainimportspec@spec.describe(route="/behavior-example/")deftest_example_body(client):"""GIVEN behavior in bodyWHEN example behavior endpoint is called with POST methodTHEN response with status 200 and body OK is returned"""assertclient.post("/behavior-example/",json={"name":"behavior"},headers={"spec-example":test_example_body.id}).json()=={"message":"OK"}Impliment solution in/main.pyfile:fromfastapiimportFastAPIfrompydanticimportBaseModelfrompytest_apiimportASGIMiddlewareapp=FastAPI()spec=ASGIMiddlewareapp.add_middleware(spec)app.openapi=spec.openapi_behaviors(app)classBehavior(BaseModel):name:str@app.post("/behavior-example/")asyncdefexample_body(behavior:Behavior):return{"message":"OK"}Run FastAPI app:poetryrunuvicorntest_app.main:app--reloadOpen your browser tohttp://localhost:8000/docs#/too find the doc string is populated into the description.Implimentation DetailsUnder the hood theASGIMiddlewareuses thedescribedecorator to store thepytestfunction by itsid:defwrap_behavior(*args,**kwargs):try:BEHAVIORS[route]exceptKeyErrorase:ifrouteine.args:BEHAVIORS[route]={str(id(func)):func}BEHAVIORS[route][str(id(func))]=funcWhenpytestcalls your API theSpecificationResponderis looking for the corespondingidin theheadersof the request:defhandle_spec(self,headers):behaviors=BEHAVIORS[self.path]self.should_update_example=headers.get("spec-example","")inbehaviorsself.should_update_description=(headers.get("spec-description","")inbehaviors)ifself.should_update_example:self.func=behaviors[headers.get("spec-example")]elifself.should_update_description:self.func=behaviors[headers.get("spec-description")]This is possible thanks to python's first-classfunctionsi.e.Closure_(computer_programming).
Package: pytest-approvaltests
A plugin to use approvaltests with pytestFeaturescommand line options to choose which reporter to use on approval test failuredefine your own diff reporter to use on approval test failureRequirementsapprovaltestsInstallationYou can install “pytest-approvaltests” viapipfromPyPI:$ pip install pytest-approvaltestsUsageSee also the documentation forapproval testsWhen your approval tests fail and you are working interactively, you might like
it to open another diff tool than when you are on a CI server for example.This plugin allows you to configure pytest with which diff tool to use when tests fail.To set the default reporter to ‘PythonNativeReporter’, suitable for use on the command line:pytest –approvaltests-use-reporter=’PythonNativeReporter’To define your own diff reporter, perhaps a program with a rich GUI installed only on your developer workstation:pytest –approvaltests-add-reporter=”diff_program”The value for ‘approvaltests-add-reporter’ should be an executable program that can diff two files received as arguments on the command line like this:diff_program filepath1 filepath2if it takes additional arguments, add them with ‘approvaltests-add-reporter-args’:pytest –approvaltests-add-reporter=”diff_program” –approvaltests-add-reporter-args=”arg1,arg2”They will be inserted like this:diff_program arg1 arg2 filepath1 filepath2Tip for Jetbrains toolbox and PyCharm usersYou can use PyCharm as a diff tool, which is convenient if you are also using it as an IDE.
Especially if you’re using Toolbox, it can be difficult to find the actual executable to pass to pytest.
You could try this while PyCharm is running:ps -ef | grep PyCharmIf you’re lucky it will show the full path to the PyCharm that is executing. It may not be pretty.
However, then you can configure pytest with arguments something like this:–approvaltests-add-reporter-args=’diff’ –approvaltests-add-reporter=’/Users/emily/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/PyCharm.app/Contents/MacOS/pycharm’In PyCharm, you can create a new ‘run configuration’ (see the [documentation](https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html)).
Add a configuration using the ‘+’ button, choose “python tests | pytest”.
Add these arguments to set the reporter for pytest under ‘Additional Arguments’.ContributingContributions 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-approvaltests” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Developer NotesTo release a new version on pypi:python setup.py installcheck it created an egg file under distpython -m twine upload dist/pytest_approvaltests-<version>-py3.7.eggYou will need to enter a valid username and password for pypi
Package: pytestarch
Welcome to PyTestArchPyTestArch is an open source library that allows users to define architectural rules and test their code against them. It is
generally inspired byArchUnit.Installation GuidePyTestArch is available viaPyPIand can be installed e.g. via pip:pip install pytestarch. To also install the
optional dependency matplotlib, which is required to draw the created dependency graphs, installpytestarch[visualization]Usage GuideThree steps are required to test an architectural rule:Create an evaluable representation of the source code you want to testfrom pytestarch import get_evaluable_architecture

evaluable = get_evaluable_architecture("/home/dummy/project", "/home/dummy/project/src")This will scan all python files under /home/dummy/project/src for imports and build an internal representation that can
later be queried. The first parameter /home/dummy/project helps PyTestArch to differentiate between internal and external
dependencies. This evaluable can be used for multiple architectural rule checks; if you are usingpytest,
you could use a fixture for this evaluable object.Define an architectural rulefrom pytestarch import Rule

rule = (
    Rule() 
    .modules_that() 
    .are_named("src.moduleB") 
    .should_not() 
    .be_imported_by_modules_that() 
    .are_sub_modules_of("src.moduleA") 
)This rule represents the architectural requirements that a module named "src.moduleB" should not be imported by any module
that is a submodule of "src.moduleA", excluding "src.moduleA" itself.Evaluate your code against this rulerule.assert_applies(evaluable)That's it!
Package: pytest-argus
pytest_argus is the Python plugin for pytest that colects results and stores them.InstallingThe main branch always contains the latest official release. Official releases are posted toPyPI.The dev branch contains improvements and fixes of the current release that will go into the next release version.To install the official release just runpip install--upgradepytest-argus.To install the version ingithubusepython setup.py developfor development install orpython setup.py install.TestingUnit tests can be invoked by runningpython setup.py testcommand.We strongly recommend that you test the package installation and unit test execution against the python environments listed in ‘’tox.ini’’.For this you can usetoxutility. Run the following:yum install python-toxtoxDocumentationFor general documentation see <https://github.com/keysight/argus>pytest_argus / Python Supportpytest_argus supports:Python 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9Compatibility with older versions may continue to work but it is not actively supported.
Package: pytest-aspec
Apspec formatreporter for pytestInstallpip install pytest_aspecUsageAdd the parameter–pspecwhen runningpytest. Ex:pytest --pspec your-tests/Tip: If you don’t want to type--pspecevery time you runpytest, add it
toaddoptsin yourini file. Ex:# content of pytest.ini# (or tox.ini or setup.cfg)[pytest]addopts=--pspecDemo CodeAdd the doc strings Ex:importunittestclassTestWayTwo(unittest.TestCase):"Pspec Python TDD"deftest_should_add(self):"it adds two integers and returns integer"self.assertEqual(2+2,4)deftest_should_find_difference_between_integers(self):self.assertEqual(4-2,2)runningpytest--pspecoutputsdemo
 🌸 it adds two integers and returns integer
 🌸 should find difference between integersConfiguration file optionspspec_passedSpecifies pspec passed character. Ex:# content of pytest.ini# (or tox.ini or setup.cfg)[pytest]pspec_passed=\N{heavy check mark}\N{vs16}$ pytest test_demo.py
============================= test session starts ==============================
platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /private/tmp/demo, inifile: pytest.ini
plugins: pspec-dev
collected 2 items

test_demo.py
Pytest pspec
 ✔️ prints a BDD style output to your tests
 ✔️ lets you focus on the behaviorpspec_failedSpecifies pspec failed character. Ex:# content of pytest.ini# (or tox.ini or setup.cfg)[pytest]pspec_failed=\N{skull and crossbones}\N{vs16}$ pytest test_demo.py
============================= test session starts ==============================
platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /private/tmp/demo, inifile: pytest.ini
plugins: pspec-dev
collected 2 items

test_demo.py
Pytest pspec
 🌸️ this failed??!!pspec_skippedSpecifies pspec skipped character. Ex:# content of pytest.ini# (or tox.ini or setup.cfg)[pytest]pspec_skipped=\N{snowman without snow}\N{vs16}$ pytest test_demo.py
============================= test session starts ==============================
platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /private/tmp/demo, inifile: pytest.ini
plugins: pspec-dev
collected 2 items

test_demo.py
Pytest pspec
 ☃️️ skipping this test for now
Package: pytest-asptest
# ASP test[pytest](https://docs.pytest.org) plugin to test ASP source code.The principle is simple: you write inputs and outputs in a dedicated file, you run pytest,pytest tells you which outputs are missing or unexpected.## Installationpip install pytest-asptestObviously, in order to run ASP, a solver must be installed. The only one handled for now is [clingo](https://github.com/potassco/clingo/releases)from [potassco labs](https://potassco.org).## simple exampleLet's consider `dumbasp.lp`, an ASP code we want to be tested:```aspp(1..3).q(X): p(X).```We want to test the rule in second line. We therefore put it into a block (consecutive lines without blank lines)and give it a tag, `rule-q`:```aspp(1..3).% TEST: rule-qq(X): p(X).```Now we fill `test-rule-q.lp` with multiple tests:```asp% INPUT% empty test: no input, no output% INSATISFIABLE% INPUTp(1).% OUTPUTq(1).% OUTPUTq(2).  % This will lead to an error : there is no such answer set.```Now, we can run again asptest:pytest dumbasp.lpIt will report the testing process, indicating which tests are passed, and which are not.More examples are available in the [Makefile](Makefile), or in [examples/](examples/)## features- multiple files support ; tags are shared- handle generation of multiple answer sets, and strict keyword### strict outputBy default, the atoms given in output parts must be a *subset* of the atoms present in the answer set.However, if you want to explicitely give *all* atoms that must appear in a given answer set,you can write `% STRICT OUTPUT` instead of `% OUTPUT` in the test file.### file uidThe file uid is given by default to all blocks of a file, and is the basename of the file.You can therefore implement `test-queens.lp` to test all the blocks found in file `queens.lp`,without having to manually tag all your blocks with it.### CLI optionsasptest add one option to pytest: `--uid-tests-dir`, allowing user to give to asptest the directory in which the `test-*.lp` files are.For instance, `pytest . -vv --uid-tests-dir asp-test` would allow you to test all ASP files in the current directory, using the test files in `asp-test/` dir.## TODO- auto include input code into output with flag *with-output* on OUTPUT lines in test files
Package: pytest-assertcount
AssertCountA pytest plugin to count the actual number of asserts in a pytest run.OutputThe output will be shown as the second last result in the pytest output, right aboveshort test summary info.Example:...=====assertstatistics=====totalasserts:1passedasserts:1(100%)failedasserts:0(0%)==shorttestsummaryinfo==...The plugin is only able to count asserts intest_XYZ.pyfiles. When usingutils-files name themtest_utils.SetupIn order to use the plugin, you have to define apytest.inifile in the root directory of your project.
This file should contain the following lines:[pytest]enable_assertion_pass_hook=true
Package: pytest-assertions
Pytest AssertionsScope of assertions methods, which provides simple interface for creating checks in autotestsExamplesfromhttpimportHTTPStatusfromassertionsimportassert_fromassertions.operatorsimportOperatorsassert_(True,what='user_id',operator=Operators.TRUTH)assert_(None,what='user_id',operator=Operators.NULL)assert_(5,5,what='user_id',operator=Operators.EQUAL)assert_('a',['a'],what='user_id',operator=Operators.CONTAINS)assert_(6,5,what='user_id',operator=Operators.GT)assert_(4,5,what='user_id',operator=Operators.LT)assert_(False,what='user_id',operator=Operators.NOT)assert_(5,6,what='user_id',operator=Operators.NOT_EQUAL)assert_(200,HTTPStatus.OK,what='user_id',operator=Operators.STATUS_CODE)assert_({"id":1},{"id":1},what='user_id',operator=Operators.EQUAL)Build in solutionsfromassertionsimportassert_all,assert_any,assert_ltemy_value=[{'name':1},{'name':2},{'name':3}]api_response_value=[{'name':1},{'name':2},{'name':3}]assert_all(api_response_value,my_value,'my_value',['name'])assert_any(api_response_value,my_value,'my_value',['name'])left_value=1right_value=2assert_lte(left_value,right_value,'My value count')Full list of solutionsassert_
assert_all
assert_any
assert_lte
assert_truth
assert_attr
assert_json
assert_response_status
assert_model_equal
validate_json
Package: pytest-assurka
pytest-assurka: A pytest plugin for Assurka StudioPre-InstallationThe api requests use therequestspackage and this may need to be installed first.pip install requestsInstallationpip install the package to your project's virtual environment. Directly from plugin folder:pipinstall-e.or pip install it from Pypi:pipinstallpytest-assurkaActivate the plugin with the pytest cli with the command:pytest--assurka-projectId={projectId}--assurka-secret={secret}--assurka-testPlanId={testPlanId}You can get the above keys from Assurka Studiohttps://studio.assurka.io