Saravanan666/pypi-org huggingface dataset:
Package: pytest-notion
notion-pytest-reporterA PyTest Reporter to send test runs to Notion.so and enable bi-directional
traceability.Test Cycle Report - Shows Test Execution Results from runTest Execution - Shows Stack trace if failedTest Case - Shows Test ExecutionsHow it worksnotion-pytest-reporteruses the unofficial Notion API to create new items in
the Test collection templates found here:Test Report TemplateFor every test runnotion-pytest-reporterwill create a new Test Cycle and
within the Test Cycle create a Test Execution.The Test Execution can be linked to a Test Case using the@pytest.mark.notion_test(test_name)decorator
with thetest_nameargument being the title of the test case.If a Test Case has been linked to a Test Execution then the Test Case page will
be updated to show that Test Execution allowing for bi-directional traceability
between the executed test and the test case.If the Test Case is linked to a user story or specification then you'll
have bi-directional traceability between the tests and the user story!Running the reporterThe reporter takes the following arguments:ArgumentDescription--notion-tokenAPI token used to authenticate with Notion--test-cycle-urlURL of the Test Cycle collection--test-case-urlURL of the Test Case collection--test-execution-urlURL of the Test Execution collection--test-cycle-nameName to use for the Test CycleAll arguments execpt--test-cycle-nameare required for the reporter to run.Getting the Authentication Token and collections URLSIn order to get the authentication token used by the test reporter
you'll need to use the web version of Notion.Once you've logged into Notion open the inspector panel on your web browser
and locate the cookie namedtoken_v2- the value stored in that cookie is
authentication token.The Test Cycle and Test Case URLs are simpler to extract.Right click the Test Cycle page in the side navigation and selectCopy Linkto
get the URL for the Test Cycle collection.Right click the Test Cases page in the side navigation and selectCopy Linkto
get the URL for the Test Cases collection.Right click the Test Executions page in the side navigation and selectCopy Linkto
get the URL for the Test Executions collection.
Package: pytest-nunit
A pytest plugin for generating NUnit3 test result XML outputRequires:
- Pytest 5.1.0+
- Python 3.7+Command-line options--nunit-xmlA string value to set the file name of the generated XML file.Argument takes a path to the output file, either relative, or absolute.--nunit-prefixA string value to prefix all test case names the string provided.Defaults to an empty string.INI Optionsnunit_show_usernameBoolean value to include the system username in the test run properties.Defaults tofalsenunit_show_user_domainBoolean value to include the system user domain in the test run properties.Defaults tofalsenunit_suite_name(Deprecated, value ignored)String value to set the test suite name.Defaults to'pytest'nunit_attach_onEnumeration to control whether the attachments property is set on all test cases when theadd_nunit_attachmentis used.Can be one of:any- Include test attachments for all outcomes (Default)pass- Include test attachments for only passed test casesfail- Include test attachments for only failed test casesFixturesThe following fixtures are made available by this plugin.record_nunit_propertyCallingrecord_nunit_property(key: str, value: str)will result inPropertytags being added to thetest-casefor the related node.deftest_basic(record_nunit_property):record_nunit_property("test","value")assert1==1add_nunit_attachmentAdd an attachment to a node test-case by calling theadd_nunit_attachment(path: str, description: str)function with the filepath and a description.deftest_attachment(add_nunit_attachment):pth=os.path.join(os.path.abspath(os.path.dirname(__file__)),'fixture.gif')add_nunit_attachment(path,"peanut butter jelly time")assert1==1Usage with Azure PipelinesAdd the following steps to your build job to publish the results to Azure Pipelines:-script:"pipinstallpytest-nunit"-script:|python -m pytest tests -v --nunit-xml=test-results.xmlcontinueOnError:true-task:PublishTestResults@2inputs:testResultsFormat:NUnittestResultsFiles:'**/test-results.xml'Skipped TestsSkipped tests will have thereasonattribute (if provided) included in the results.AttachmentsUsing theadd_nunit_attachmentfixture will render any attachments in the “attachments” tab inside the Tests console:Failures and xfailsAny failed tests, whether as xpass or xfail, will have the error output and comparison, as well as the failing line in the stack trace.Compatibility with other pluginsx-distWhen running with-f, make sure to add in your pytest config file (setup.cfg etc)looponfailroots = testdirto exclude xml report files from being watched for changes.Checklooponfails
Package: pytest-object-getter
PYTEST OBJECT GETTERA Pytest Plugin providing theget_objectfixture.Code:https://github.com/boromir674/pytest-object-getterDocs:https://pytest-object-getter.readthedocs.io/en/master/PyPI:https://pypi.org/project/pytest-object-getter/CI:https://github.com/boromir674/pytest-object-getter/actions/Highlightspytest_object_getterpython package, hosted onpypi.orgInstallable withpipget_objectfixture available to your testsDynamically import an object from a moduleOptionally mock any object that is present in the module’s namespaceConstruct the mock object at runtimeAlter the bahaviour of an object at runtimeTested against multipleplatformsandpythonversionsplatforms: Ubuntu, MacOSpython: 3.6, 3.7, 3.8, 3.9, 3.10For more, see theCI Pipelineand theTestworkflow, defined intest.yaml.You can read more on pytest and fixtures inpytest latest documentation.QuickstartPrerequisitesYou need to havePythoninstalled.InstallingUsingpipis the approved way for installingpytest_object_getter.python3-mpipinstallpytest_object_getterAfter installation theget_objectpytest fixture should be available in your tests.A Use CaseLet’s see how to write a test and use the ‘get_object’ fixture to mock
therequests.getmethod to avoid actual network communication:python3-mpipinstallask-pypiimportpytest@pytest.fixturedefmock_response():definit(self,package_name:str):self.status_code=200ifpackage_name=='existing-package'else404returntype('MockResponse',(),{'__init__':init})@pytest.fixturedefcreate_mock_requests(mock_response):def_create_mock_requests():defmock_get(*args,**kwargs):package_name=args[0].split('/')[-1]returnmock_response(package_name)returntype('MockRequests',(),{'get':mock_get,})return_create_mock_requestsdeftest_fixture(get_object,create_mock_requests):fromask_pypiimportis_pypi_projectassertis_pypi_project('numpy')==Trueassertis_pypi_project('pandas')==Trueassertis_pypi_project('existing-package')==Falseget_object('is_project','ask_pypi.pypi_project',overrides={'requests':lambda:create_mock_requests()})assertis_pypi_project('existing-package')==Trueassertis_pypi_project('numpy')==Falseassertis_pypi_project('pandas')==Falseassertis_pypi_project('so-magic')==FalseLicenseFree software:GNU Affero General Public License v3.0DevelopmentHere 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 Suite
Package: pytest-odc
pytest-odcApytestpluginfor simplifyingOpen Datacubedatabase tests.Testing Open Datacube ApplicationsAnyone writing applications using an ODC Database needs to be able to test their code. This requires an ODC Database containing a known set of data.There's two challenges here:ODC requires a PostgreSQL server accessible anywhere test are run, which can be challenging to set up.The database should be reset every time a test is run, to make it possible to repeatedly run tests.The SolutionThis package provides reusablepytestfixtures, to make it easy to write test code against an ODC Database. It handles starting and stopping a temporary PostgreSQL server using Docker, initialising it for ODC use, and loading/wiping sets of test data on a per test module basis.Steps to Create New TestsInstall theODC Test Plugininto your Python environment.pip install pytest-odcCreate at least one each of an ODCMetadata Type,ProductandDatasetYAML files. These will be loaded into an ODC Database before your test code runs.Create apytestfile using this template:"""Template pytest module for testing ODC Code"""importpytest# UPDATE: these lists with the data you want loaded into your database# Each string is for a file, relative to this python module.METADATA_TYPES=["metadata/eo3_metadata.yaml",]PRODUCTS=["products/ga_ls8c_ard_3.odc-product.yaml",]DATASETS=["datasets/ga_ls8c_ard_3-sample.yaml",]# Use the 'auto_odc_db' fixture to populate the database with sample data.pytestmark=pytest.mark.usefixtures("auto_odc_db")deftest_my_odc_code(odc_db:"datacube.Datacube"):### REPLACE: with your own test codemy_datasets=odc_db.find_datasets(product='ga_ls8c_ard_3')assertlen(my_datasets)==3Run your new tests.pytest tests/More Details / How it WorksThe four provided pytest fixtures compose together to ensure an ODC Database is available and preloaded with test data for each test module.Fixturespostgresql_serverThis fixture either:Runs a temporary PostgreSQL server using DockerOr checks that a test PostgreSQL server is already available via theODC_TEST_DB_URLenvironment variable.odc_dbThis fixture provides adatacube.Datacube()object configured to connect to the temporary test database.It can be added to the parameters for a test for getting access to the temporary database.odc_test_dbThis fixture creates all the ODC Database tables.auto_odc_dbThis fixture should be used as apytestmark autoload, marking the test module as having variables namedMETADATA_TYPES,PRODUCTSandDATASETSbeing lists of files to load into the test database.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 theApache Software License
2.0license,
"pytest-odc" is free and open source softwareIssuesIf you encounter any problems, pleasefile an
issuealong
with a detailed description.Release Process# Update version number!
git tag {version_number}
rm -rf dist/
python -m build
twine upload --repository testpypi dist/*
twine upload dist/*
Package: pytest-odoo
pytest plugin to run Odoo testsThis lib allows to run the tests built in Odoo addons which are using Python’sunittest, but with the comfort of thepytestCLI.
Also allowing to run tests without updating given module.Odoo’s–test-enablemachinery and pytest-odoo do not cover exactly the same scope. The Odoo’s test runner runs the tests during
the upgrades of the addons, that’s why they need the “at install” and “post install” markers.Running tests during upgrades of addons is waaay too slow to work efficiently in a TDD mode, that’s where pytest-odoo shines.
Consider that all the tests are runningpost-installwith pytest-odoo, as you must run the upgrade of the addon before (but only when needed vs each run).At the end of the day, its beneficial to run the Odoo tests with–test-enablebecause, as in very rare conditions,
a test can pass with pytest-odoo but not with the “at install” tests run during the upgrade (or the oposite).
Pytest-odoo can be considered a development tool, but not the tool that should replace entirely–test-enablein a CI.See also theofficial Odoo documentationon writing tests.Usageinstall via:pip install pytest-odoousage:pytest -s --odoo-database=test --odoo-log-level=debug_sql [--odoo-http]The custom options are:--odoo-database: name of the database to test.--odoo-log-level: log level as expected by odoo. As time of writing: info, debug_rpc, warn, test, critical, debug_sql, error, debug, debug_rpc_answer. The default is critical to have a clean output.--odoo-config: path of the odoo.cfg file to use.--odoo-http: Allow to launch the Odoo http instanceAlternatively, you can use theOPENERP_SERVERenvironment variable using an odoo configuration file, containing at least thedatabaseoption with the name of the database to test:export OPENERP_SERVER=/path/to/odoo/config.cfg
pytest ...
Package: pytest-oerp
py.test plugin for testing OpenERP modulesUsageinstall/update via:pip install -U pytest-oerpand to run tests type:py.test --oerp-server-path=<path to openerp server directory> \
        --oerp-db=<db name, default is test>this will load OpenERP using the config on~/.openerp_serverrcand create a pool and transaction for the choosen database for the testcases where you receive anoerpattribute.Writting testsTestcases only need to receiveoerpto create a transaction on oerp an example follows:def test_simple(oerp):
    product_obj = oerp.pool.get('product.product')
    product_ids = product_obj.search(oerp.cr, 1, [])this will be run inside OpenERP like code in modules and you can use the full openerp api. You can only load stuff from OpenERP library inside functions, because the library is added to sys.path dynamically.OpenERP APIAs pytest-oerp is running inside OpenERP everything you need to do that can be done inside a module can be done in a pytest-oerp test. The usualcr,uidattributes areoerp.crand1(that means the first user, usually admin).oerpalso has apoolattribute that is useful.TodoThere are a lot of polish and features that should be done but a tentative list would be:support passing a configuration to OpenERPmore tests (always a good thing)don’t depend on mock (great lib but probably unnecessary for this)redirect print logaddini in pytest so you can configure with pytest.inilettuce support, but this will probably go in another packageNotesThe official repository of this plugin is athttp://github.com/santagada/pytest-oerpFor more info on py.test seehttp://pytest.orgAll work on the plugin has been sponsored by PROGE (http://www.proge.com.br)
Package: pytest-ogsm-plugin
pytest-ogsm！！！如果安装了pytest-html这个插件，请先卸载，不然会有冲突！！！1、插件介绍针对特定项目定制化插件，优化了pytest报告展示方式，运行用例时可以自定义参数--report=report.html # 指定报告名
--title=指定报告标题
--tester=指定报告的测试人员
--desc=指定报告中的项目描述
可以同时使用多个参数2、安装本项目基于python3.9开发，需确认你的Python≥3.9安装命令pip install pytest-ogsm-plugin3、其他
Package: pytest-ok
OKThe ultimate pytest output pluginFeaturesPrints 'OK' after every test is runInstallationYou can install "pytest-ok" viapip_ fromPyPI_::$ pip install pytest-okLicenseDistributed under the terms of theBSD-3license, "pytest-ok" is free and open source softwareIssuesIf you encounter any problems, please file an issue along with a detailed description.
Package: pytest-only
Only run tests marked with@pytest.mark.only. If none are marked, all tests run as usual.Borrowed frommocha.Installationpipinstallpytest-onlyUsageUse it on functionsimportpytestdeftest_that_will_not_run():assert0@pytest.mark.onlydeftest_that_will_run():assert1$py.test-vtest_example.py=============================testsessionstarts==============================platformlinux--Python3.6.1,pytest-3.0.7,py-1.4.33,pluggy-0.4.0--/tmp/example/bin/python3.6cachedir:.cacherootdir:/tmp/example,inifile:plugins:only-1.0.0collected2itemstest_example.py::test_that_will_runPASSED===========================1passedin0.00seconds===========================Or use it on classesimportpytestclassTestThatWillNotRun:deftest_that_will_not_run(self):assert0@pytest.mark.onlyclassTestThatWillRun:deftest_that_will_run(self):assert1$py.test-vtest_example.py=============================testsessionstarts==============================platformlinux--Python3.6.1,pytest-3.0.7,py-1.4.33,pluggy-0.4.0--/tmp/example/bin/python3.6cachedir:.cacherootdir:/tmp/example,inifile:plugins:only-1.0.0collected2itemstest_example.py::TestThatWillRun::test_that_will_runPASSED===========================1passedin0.00seconds===========================Or use it on modules# test_example.pyimportpytestpytestmark=pytest.mark.onlydeftest_that_will_run():assert1# test_example2.pydeftest_that_will_not_run():assert0$py.test-vtest_example.pytest_example2.py=============================testsessionstarts==============================platformlinux--Python3.6.1,pytest-3.0.7,py-1.4.33,pluggy-0.4.0--/home/they4kman/.virtualenvs/tmp-53d5944c7c78d28/bin/python3.6cachedir:.cacherootdir:/home/they4kman/.virtualenvs/tmp-53d5944c7c78d28,inifile:plugins:only-1.0.0collected2itemstest_example.py::test_that_will_runPASSED===========================1passedin0.00seconds===========================Disable for single test runTo run all the tests, regardless of whether@pytest.mark.onlyis used, pass
the--no-onlyflag to pytest:$py.test--no-onlyIf--no-onlyhas already been passed (perhaps by way ofaddoptsinpytest.ini), use the--onlyflag to re-enable it:$py.test--no-only--onlyPylint checkerIf you use pylint, you can avoid committing strayonlymarks with the bundled plugin. Just enable the pylint checker in your plugins and enable theunexpected-focusedrule.[MASTER]load-plugins=pytest_only.ext.pylint[MESSAGES CONTROL]enable=unexpected-focused$cattest_ninja.pyimport pytest

@pytest.mark.only
def test_ninja():
    pass$pylinttest_ninja.py************* Module mymain
test_ninja.py:3:0: W1650: Unexpected focused test(s) using pytest.mark.only: def test_ninja (unexpected-focused)DevelopmentInstall the test/dev requirements usingPoetrypoetryinstallRun the testspy.testRun the tests on all currently-supported platformstox
Package: pytest-openfiles
This package provides a plugin for thepytestframework that allows
developers to detect whether any file handles or other file-like objects were
inadvertently left open at the end of a unit test. It has been moved from the
coreastropyproject since it is of use more generally.MotivationThepytest-openfilesplugin allows for the detection of open I/O resources
at the end of unit tests.  This is particularly useful for testing code that
manipulates file handles or other I/O resources. It allows developers to ensure
that this kind of code properly cleans up I/O resources when they are no longer
needed.InstallationThepytest-openfilesplugin can be installed usingpip:$ pip install pytest-openfilesIt is also possible to install the latest development version from the source
repository:$ git clone https://github.com/astropy/pytest-openfiles
$ cd pytest-openfiles
$ python ./setup.py installIn either case, the plugin will automatically be registered for use withpytest.UsageThis plugin adds the--open-filesoption to thepytestcommand.  When
running tests with--open-files, if a file is opened during the course of a
unit test but that file is not closed before the test finishes, the test will
fail.In some cases certain files are expected to remain open between tests. In order
to prevent these files from causing tests to fail, they can be ignored using
the configuration file variableopen_files_ignore. This variable is added
to the[tool:pytest]section of a package’s top-levelsetup.cfgfile.Files can be ignored using a fully specified filename:[tool:pytest]
open_files_ignore = "/home/user/monty/output.log"It is also possible to ignore files with a particular name regardless of where
they reside in the file system:[tool:pytest]
open_files_ignore = "output.log"In this example, all files namedoutput.logwill be ignored if they are
found to remain open after a test completes. Paths and filenames can include*and?as wildcards:[tool:pytest]
open_files_ignore = "*.ttf"It is also possible to ignore open files for particular test cases by
decorating them with theopenfiles_ignoredecorator:import pytest

@pytest.mark.openfiles_ignore
def test_open_file_and_ignore():
    """We want to ignore this test when checking for open file handles."""The test function will not be skipped, but any files that are left open by the
test will be ignored by this plugin.Development StatusQuestions, bug reports, and feature requests can be submitted ongithub.LicenseThis plugin is licensed under a 3-clause BSD style license - see theLICENSE.rstfile.
Package: pytest-opentmi
pytest reporting plugin for opentmipytest plugin to upload results to opentmi server.
Plugin collect various metadata against opentmi Result -schema.
User can extend details using pytest metadata plugin.UsageInstall using pip:pip install pytest-opentmiplugin is enabled by using--opentmiCLI argument.Running with pytest:pytest --opentmi <host> --opentmi_token <token> [--opentmi_store_logs]Configurationenv variableOPENTMI_MAX_EXEC_NOTE_LENGTHcan be used to cut long failure notes. Default 1000 characters.metadatamodule utilize some special pytest metadata keys.
Usage:pytest --metadata <KEY> <VALUE> ...Keys:Device Under Test:DUT_TYPE(hw, simulator)DUT_SERIAL_NUMBERDUT_VERSIONDUT_VENDORDUT_MODELDUT_PROVIDERSoftware Under Test:SUT_COMPONENT(array)SUT_FEATURE(array)SUT_COMMIT_IDSUT_BRANCH
Package: pytest-operator
pytest-operatorPyTest plugin to make it easy to create integration tests for Operator Charms.UsageIncludepytest-operatorin thedepsof yourtox.inifile:[testenv]deps=pytestpytest-operatorThen, just start using theops_testfixture in your async tests.  This
module-scoped fixture provides a libjuju Model, helpers to build charms for
testing, and the ability to abort testing so that the remaining tests in the
module are automatically xfailed (you can also mark a test so that this happens
automatically if the test fails; this is typically used on the initial deployment
test, where subsequent tests depend on the deployment having succeeded).As an additional nicety, you don't have to explicitly mark an async test with@pytest.mark.asyncio; if it's a test function / method and it's async, it
will be marked automatically.Example:importpytest@pytest.mark.abort_on_failasyncdeftest_build_and_deploy(ops_test):my_charm=awaitops_test.build_charm(".")awaitops_test.model.deploy(my_charm)awaitops_test.model.wait_for_idle()asyncdeftest_status(ops_test):assertops_test.model.applications["my-charm"].units[0].workload_status=="active"Building/Downloading Charm ResourcesQuite often, when charms are preparing for integration tests, the charms may
need to attach resources to the charm for it to function. In these cases,
the integration code must either build the resources or pull those from external resources.Example:asyncdeftest_build_and_deploy(ops_test):charm=awaitops_test.build_charm(".")build_script=Path.cwd()/"build-charm-resources.sh"resources=awaitops_test.build_resources(build_script)ifresources:# created a dict from list of a filenamesresources={rsc.stem:rscforrscinresources}else:arch_resources=ops_test.arch_specific_resources(charm)resources=awaitops_test.download_resources(charm,resources=arch_resources)assertresources,"Failed to build or download charm resources."log.info("Build Bundle...")bundle=ops_test.render_bundle("tests/data/bundle.yaml",charm=charm,**resources)log.info("Deploy Bundle...")juju_cmd=["deploy","-m",ops_test.model_full_name,str(bundle)]rc,stdout,stderr=awaitops_test.juju(*juju_cmd)assertrc==0,f"Bundle deploy failed:{(stderrorstdout).strip()}"awaitops_test.model.wait_for_idle()...ReferenceMore details can be found inthe reference docs.