Saravanan666/pypi-org huggingface dataset:
Package: pytest-isolate
pytest-isolateIsolate each test in a subprocess - pytest forked replacement, based on pytest-forked.This pytest plugin was generated with Cookiecutter along with@hackebrot'scookiecutter-pytest-plugintemplate.FeaturesRun each test in an forked, isolated subprocessCaptures stdout & stderr of crashing processesAdd Timeout to a forked testLimit memory used by testPlays nice with pytest-xdistShows warnings, even with xdist!RequirementspytestInstallationYou can install "pytest-isolate" viapipfromPyPIpip install pytest-isolateUsagepytest --isolateTo run every test in its ownforkedsubprocess.Or:pytest --isolate-timeout 10 --isolate-mem-limit 1000000To set a timeout to every test in addition to forking.Note:Since this plugin usesfork, it will not work on  operating systems withoutforksupport (e.g. Windows).The flags--timeoutor--forkedwill also be respected such thatpytest-isolateis a drop-in replacement forked pytest forked and pytest timeout.Ifpytest-forkedorpytest-timeoutare installed, then
they will take precedence. Uninstall them to usepytest-isolate.Unlikepytest-timeout, timeout inpytest-isolateis implemented by forking the test to a separate subprocess, and setting timeout for that subprocess.You can also use a mark to isolate or time limit the memory test:@pytest.mark.isolate(timeout=10,mem_limit=10**6)deftest_something():passThe options can also be set in an pytest configuration file, e.g:[tool.pytest.ini_options]isolate_timeout=10isolate_mem_limit=1000000ContributingContributions 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 theMIT,pytest-isolateis free and open source softwareIssuesIf you encounter any problems, please file an issue along with a detailed description.
Package: pytest-is-running
pytest plugin providing a function to check if pytest is running.Unmaintained (2024-01-02)I stopped maintaining this package as it doesn’t provide much value over checking whether pytest has been imported:importsysif"pytest"insys.modules:...In every project I’ve seen, pytest is only imported when running.Working on a Django project?Check out my bookBoost Your Django DXwhich covers many ways to improve your development experience.
I created pytest-is-running whilst working on the book!InstallationInstall with:python-mpipinstallpytest-is-runningPython 3.8 to 3.12 supported.Usagepytest will automatically find the plugin and use it when you runpytest.
You can check if pytest is running with theis_running()function:importpytest_is_runningifpytest_is_running.is_running():...The package avoids importing pytest if it is not running, so that you don’t incur that overhead in non-test paths.The package registers its plugin hooks as early as possible in pytest’s process, so it should be loaded before any of your non-test modules.RationaleThis plugin is an alternative to re-implementingthe pattern in the pytest documentation.
As a plugin, it is loaded earlier thanconftest.pyor any other code in your project.
This makes it a more robust way of checking whether pytest is currently running.Upstreamissue #9502discusses adding a feature to pytest.
It also covers an alternative which is often “good enough” - a simple check if pytest has been imported with:"pytest"insys.modulesThis won’t be strictly accurate if you happen to import pytest outside of your test run, but that is not very common.
You may prefer to using this simpler technique instead of this plugin.
Package: pytest-jelastic
Pytest-jelasticAdds the following command-line options to your pytests:--jelastic-api-url--jelastic-access-token--jelastic-env-nameand make ajelastic_env_infopytest fixture available.Publish new packageThePublishteamcity build configuration is only triggered on new git tags. Whenever a new git tag is created, the build configuration is triggered and the package published to the package manager.gittag-a1.0.0-m"my version 1.0.0"gitpushorigin1.0.0Use pluginIn your python project, firstpipinstallpytest-jelasticThen, when you run your tests, make sure to at least includepytest-ppytest_jelastic<yourotheroptions>
Package: pytest-jira-xfail
pytest-jira-xfailPlugin skips (xfail) tests linked to unresolved Jira issue(s)1. Generate your Jira API tokenYou should have Jira user
withAPI token generated2. Add PytestJiraHelper to your pytest hook:importpytestfrompytest_jira_xfail.jira_helperimportPytestJiraHelper@pytest.hookimpl(tryfirst=True)defpytest_collection_modifyitems(items):jira=PytestJiraHelper(jira_url="https://company.atlassian.net",jira_username="my_jira_user@company.com",jira_api_token="my_jira_user_api_token",)jira.process_linked_jira_issues(items)3. Link bugs to your testsfrompytest_jira_xfail.annotationsimportbug@bug("MP-123")deftest_my_test_fails():assertFalse@bug("MP-124",IndexError)deftest_my_test_broken():db_records=[]assertdb_records[0]@bug("MP-124")@bug("MP-124",IndexError)deftest_multiple_exceptions():db_records=[]assertdb_records[0][0]=='active'XFAIL message format:XFAIL The test is skipped because of open bugs:
https://company.atlassian.net/browse/MP-1234. [Optional] Set custom resolved statusesBy default, only issues with the status "Done" and "Closed" are considered as resolved.But you can override this and add more statuses, as following:importpytestfrompytest_jira_xfail.jira_helperimportPytestJiraHelper@pytest.hookimpl(tryfirst=True)defpytest_collection_modifyitems(items):jira=PytestJiraHelper(jira_url="https://company.atlassian.net",jira_username="my_jira_user@company.com",jira_api_token="my_jira_user_api_token",resolved_statuses=["Done","Closed","Released","Declined"])jira.process_linked_jira_issues(items)
Package: pytest-jobserver
pytest-jobserverLimit parallel tests with posix jobserver.InstallationInstall with pip:pipinstallpytest-jobserverThe plugin officially supports Python>= 3.6on a Linux OS.
You may find other Python 3 versions/MacOS work as well.UsageThe plugin uses aPOSIX jobserverto manage parallel test loading.Pass the--jobserverargument with a path, where this path points to a named pipe acting as a jobserver.
You should probably also usepytest-xdistto enable parallelism in the first place:pytest-n4--jobserver/opt/jobserverYou can also pass this filepath via thePYTEST_JOBSERVERenvironment variable.makeThe plugin can also listen for an existing jobserver as created bymake.
If a jobserver is not configured by filepath,pytest-jobserverwill check the following environment variables in order:CARGO_MAKEFLAGSMAKEFLAGSMFLAGSPlease note:it is not possible to use one of these environment variables withpytest-xdist. Theexecnetprotocol used byxdistdoes not support passing file descriptors to remote child processes.ImplementationThis pluginwraps pytest's call topytest_runtest_protocol, which is called to actually run a collected item on the worker node.DevelopmentSee the top levelMakefileand.circleci/config.ymlfor the development flow. But in essence:make devto install depsmake lintto lint code (will change files)make testto run lint/unit testsmake integrateto run integration testsChangelog1.0.0Featuresjobserver tokenintvalue can be accessed within a test using thejobserver_tokenfixturebump to1.0.0as the plugin is now stable, and in use by other projects0.3.1Bugfixesfix package installation with pip0.3.0Featuresa jobserver filepath can also be configured by thePYTEST_JOBSERVERenvironment variable0.2.2Bugfixesmove jobserver status on startup to officialpytest_report_headerhook0.2.1Bugfixesremovepytest-xdistfrom runtime dependencies0.2.0Featurescan run against a jobserver specified withmakeenvironment variablesnote that this will deliberately not work when also usingpytest-xdist0.1.1Bugfixesfix setup.py package metadata0.1.0Featurescan run against a jobserver specified at the cliTODOrun against cli jobserverintegrate with Make jobserver from environment variablesfactor out creation of jobservers to seperate python package
Package: pytest-joke
pytest-jokeRunning tests is better with some healthy (or not) amount or humor! 😃This is a completely useless plugin created to get some practice in creating plugins for Pytest.Powered bypyjokes.Installation 🐍You can installpytest-jokeviapipfromPyPI:$pipinstallpytest-jokeUsageWhen the plugin is installed, every time a test run results in a failure, the terminal would output a random joke in an attempt to cheer you up.Humor-poweredoutputenabled😃.

plugins:mock-1.10.4,joke-0.1.0
collected2items

test_joke.py.F[100%]===================================FAILURES===================================_________________________________test_failed__________________________________deftest_failed():
>assert1==2Eassert1==2test_joke.py:7:AssertionError======================1failed,1passedin0.03seconds======================Therearetwowaystowriteerror-freeprograms;onlythethirdoneworks.TODOmake the plugin configurable: turn on/off, language, joke category, number of jokesLicenseDistributed under the terms of theMITlicense,pytest-jokeis
free and open source software.Motivation
Package: pytest-json
pytest-json is a plugin forpy.testthat generates JSON
reports for test resultsThisPytestplugin was generated withCookiecutteralong with@hackebrot’sCookiecutter-pytest-plugintemplate.RequirementsPython 2.7, 3.3, 3.4, 3.5py.test 2.7 or newerInstallationYou can install “pytest-json” viapipfromPyPI:$ pip install pytest-jsonUsage$ py.test --json=report.jsonor you can set the report path in an ini file:[pytest]
json_report = report.jsonThe command-line option will override the ini fileThere is an optional flag to normalize the generated report tojsonapi. This is intended for (easier) consumption by
ember-data and others:$ py.test --json=report.json --jsonapior you can set the jsonapi flag in an ini file:[pytest]
jsonapi = anythingNote that the value of the ini var can be anything. Presence alone will cause
it to be true.Adding to environmentYou can modifyrequest.config._json_environmentin a fixture@pytest.fixture(scope='session',autouse=True):defextra_json_environment(request):request.config._json_environment.append(('herp','derp'))Adding metadata per test stageMetadata added viastage_metadatashows up inmetadatafield of the
stage in the resulting JSON object# conftest.py@pytest.hookimpl(tryfirst=True,hookwrapper=True)defpytest_runtest_makereport(item,call):outcome=yieldreport=outcome.get_result()ifreport.when=='call':report.stage_metadata={'foo':'bar'}elifreport.when=='setup':report.stage_metadata={'hoof':'doof'}elifreport.when=='teardown':report.stage_metadata={'herp':'derp'}Addint metadata per testMetadata added on the tests themselves are represented by an array. To avoid
collisions, etc. Any stage (setup, teardown, call) that setstest_metadataon a report will have its metadata appended to the array. Metadata added viatest_metadataends up in themetadatafield of the test in the
resulting JSON object# conftest.py@pytest.hookimpl(tryfirst=True,hookwrapper=True)defpytest_runtest_makereport(item,call):outcome=yieldreport=outcome.get_result()# only add this during call instead of during any stageifreport.when=='call':report.test_metadata='whatever'Compatibility with pytest-htmlTo avoid issues with pytest-html, pytest-json usesrequest.config._json_environmentinstead ofrequest.config._environmentAdditionally, pytest-json ignores theextrafield on reports.Example jsonA formatted example of the output can be found in example.jsonThe actual output is not formatted, but this was passed through jq for
readability.A formatted example of the jsonapi output can be found in example_jsonapi.jsonContributingContributions 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-json” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-json-fixtures
JSON output for the--fixturesflagThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesThis plugin converts into JSON format the output generated when runningpytestwith the--fixturesflag.RequirementsYou must have Python, pip and pytest to use this plugin.InstallationYou can install “pytest-json-fixtures” viapipfromPyPI:$ pip install pytest-json-fixturesUsageRun the command below:$ pytest --json-fixturesThe same result you would get withpytest--fixtureswill be output in JSON.ContributingContributions are very welcome.LicenseDistributed under the terms of theMITlicense, “pytest-json-fixtures” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-jupyter
pytest-jupyterA set of pytest plugins for Jupyter libraries and extensions.Basic UsageFirst, installpytest-jupyterfrom PyPI using pip:pipinstallpytest-jupyterThis installs the basic pytest-jupyter package that includes fixture definitions for the various Jupyter-based pytest plugins.To use one of these plugins, you'll also need to install their dependencies. This requires a secondpip installcall. For example, if you'd like to use thejupyter_serverplugin, you'll need to call:pipinstall"pytest-jupyter[server]"Thisshouldinstall everything you need for the plugin to work.To use a plugin, add it to thepytest_pluginslist in theconftest.pyof your project's root test directory.# inside the conftest.pypytest_plugins=["pytest_jupyter.jupyter_server"]This library includes anecho_kernel, which is useful to speed up testing.
You must have either"pytest-jupyter[server]"or"pytest-jupyter[client]"installed to use the echo kernel.Thepytest_jupyter.jupyter_clientplugin provides an installedecho_kernel_specas a fixture, and astart_kernelfixture
that provides a factory function that starts a kernel using theechokernel
by default.Note: The server plugin also includes the client plugin, so you can use both
sets of fixtures with"pytest_jupyter.jupyter_server".  Both theclientandserverplugins also include the core fixtures.Note: The client and server plugins usepytest-tornasyncfor async
test suite running.  It may not compatible withpytest-asyncio, meaning
that all fixtures must be synchronous.  You can use theasyncio_loopfixture
and runasyncio_loop.run_until_completeagainst an async function in your
fixtures if needed.The server fixures use the echo kernel by default.  To override this behavior,
override thejp_server_configfixture and add the following config:{"MultiKernelManager":{"default_kernel_name":"<desired_kernel_name"}}All fixtures inside the plugin (e.g. jupyter_server) will be available to all of your project's unit tests. You can use a fixtures by passing it as an argument to your unit test function:asyncdeftest_jupyter_server_api(jp_fetch):# Send request to a temporary Jupyter Server Web Applicationresponse=awaitjp_fetch("api/spec.yml")# Confirm that the request is successful.assertresponse.code==200You can list the fixtures for a given plugin using the--fixturesargument from the pytest command line interface:pytest--fixtures-ppytest_jupyter.jupyter_serveror by calling thepytest --fixtureswhere the plugin is listed in thepytest_pluginsvariable of a given test directory.
Package: pytest-jupyterhub
Description|Installation|Usage|ContributingReusable JupyterHub Pytest PluginDescriptionThis is a reusable pytest plugin for testing JupyterHub's componentsJupyterHubis a modular and extensible project, with components, like theproxy,authenticatorandspawner, that can be easily replaced with alternate implementations. Testing the functionality of these components against JupyterHub is important and it requires various hub setups that can sometimes become complicated.Each of these hub components and the hub itself define their own testing infrastructure, building everything from the ground up using thepytestframework. And some of this complex work is either repetitive across JupyterHub sub-projects, or under-specified for some of them. This has sparked a need to abstract these common parts into a separate testing framework.The goal is to provide importable testing utilities to make it easier for contributors to write tests for the various hub components.
This will involve creating and usingfixturesandmocks.AFixtureis a function that is used to prepare and clean up the environment for a test function. Fixtures can be used to set up test data, test environment, and other resources that are needed by test functions.
For more information on Fixtures, check out thispytest documentationon fixtures.AMockis an object that simulates the behavior of another object such as a class or function. They are used to simulate the behavior of real objects for testing purposes.
For more information on Mocks, check out thisunittest documentationon the mock module.InstallationTo use theJupyterHub Pytest Plugin, you will first need to install it using pip:pipinstallpytest-jupyterhubUsageTo use a plugin, first register/load the plugin in your test module orconftest.pyfile:pytest_plugins="jupyterhub-spawners-plugin"To register multiple plugins:pytest_plugins=["jupyterhub-spawners-plugin","other-plugin"]For more information, check out this document onRequiring/Loading plugins in a test module or conftest fileAll fixtures and mocks inside the plugin will be available to all of your project's test suites. You can use a fixture by passing it as an argument to your test function.ExampleThehub_appfixtureis afactory fixturethat creates aMockHubinstance from a providedconfigdictionary defining spawner-specific attribute configurations. It then yields the mocked instance. After testing, the running hub instance is stopped and a cleanup is performed.An illustration of its integration within theDockerSpawnertest suiteis provided below:@pytest.fixtureasyncdefapp(hub_app):config={"Dockerspawner":{"prefix":"dockerspawner-test"}}iflen(jh_version_info)>3andjh_version_info[3]:tag=jupyterhub.__version__config["Dockerspawner"]["image"]=f"jupyterhub/singleuser:{tag}"app=awaithub_app(config=config)returnappContributingIf you would like to contribute to the project, please read ourcontributor documentationand theCONTRIBUTING.md.The contributor documentation explains how to set up a development installation, how to run the test suite, and how to contribute to documentation.
Package: pytest-kafka
Pytest fixture factories for Zookeeper, Kafka server and Kafka consumer.Read the API docs.frompathlibimportPathfrompytest_kafkaimport(make_zookeeper_process,make_kafka_server,make_kafka_consumer,terminate,)ROOT=Path(__file__).parentKAFKA_SCRIPTS=ROOT/'kafka/bin/'KAFKA_BIN=str(KAFKA_SCRIPTS/'kafka-server-start.sh')ZOOKEEPER_BIN=str(KAFKA_SCRIPTS/'zookeeper-server-start.sh')# You can pass a custom teardown function (or parametrise ours). Just don't call it `teardown`# or Pytest will interpret it as a module-scoped teardown function.teardown_fn=partial(terminate,signal_fn=Popen.kill)zookeeper_proc=make_zookeeper_process(ZOOKEEPER_BIN,teardown_fn=teardown_fn)kafka_server=make_kafka_server(KAFKA_BIN,'zookeeper_proc',teardown_fn=teardown_fn)kafka_consumer=make_kafka_consumer('kafka_server',seek_to_beginning=True,kafka_topics=['topic'])This creates 3 fixtures:zookeeper_proc- Zookeeper processkafka_server- Kafka processkafka_consumer- usablekafka.KafkaConsumerinstanceZOOKEEPER_BINandKAFKA_BINare paths to launch scripts in your Kafka distribution. Check
this project’s setup.py to see a way of installing Kafka for development.It is advised to passseek_to_beginning=Truebecause otherwise some messages may not be captured
by the consumer. This requires knowing the topics upfront because without topics there’s no
partitions to seek.Kafka server is known to take a couple of seconds to terminate gracefully. You probably don’t
need that, so you can passpartial(terminate, signal_fn=Popen.kill)to make it killed with
SIGKILL and waited for afterwards.It’s possible to create multiple Kafka fixtures forming a cluster by passing the same Zookeeper
fixture to them. For an example, check thetests.Session-scoped fixtures are also available. Consult thetest suite.System requirementsPython 3.6+a JVM that can run Kafka and ZookeeperKafka -https://kafka.apache.org/downloadsDevelopmentpipinstall-e.[dev]python./pytest_kafka/install.py# will install kafka to ./kafkaAcknowledgementsThe library has been open-sourced from a codebase belonging toInfectious Media.
Package: pytest-kafkavents
pytest-kafkaventsPyTest Kafkavents is a plugin for real time streaming of test result events to a Kafka instance.
Events can also be logged for batch replay of events via another utility (in the works).Steps to use pytest-kafkaventsClone me (soon to be pip install me)git clone https://github.com/grandcentralstation/pytest-kafkavents.gitTo install for devpip install -e .Create a Kafka instance onRed Hat OpenShift Streams for Apache KafkaDownload and install the client from theApache Kafka clientwebsite.SIDENOTE:Pytest-Kafkavent uses the Confluent Python Kafka libraryOn Fedora...dnf info python3-confluent-kafka
pip show confluent-kafkaCopy and configure app-services.properties template to your local kafka client bin directory and fill-in info for your instance.Setup env variablesexport KV_BOOTSTRAP_SERVER=my-kafka-example.rhcloud.com:443Create topics (with the client command)./kafka-topics.sh --create --topic kafkavent --bootstrap-server my-kafka-n--u-bvmxxe-dvgycp-axfjmaftyk.bf2.kafka.rhcloud.com:443 --command-config ../config/app-services.properties
./kafka-topics.sh --create --topic kafkavent-failed --bootstrap-server my-kafka-n--u-bvmxxe-dvgycp-axfjmaftyk.bf2.kafka.rhcloud.com:443 --command-config ../config/app-services.properties
./kafka-topics.sh --create --topic kafkavent-infra --bootstrap-server my-kafka-n--u-bvmxxe-dvgycp-axfjmaftyk.bf2.kafka.rhcloud.com:443 --command-config ../config/app-services.propertiesStart one consumer in one window to see pytest-kafkavent messages for all tests./kafka-console-consumer.sh --bootstrap-server $KV_BOOTSTRAP_SERVER \
    --consumer.config ../config/app-services.properties --from-beginning --topic kafkaventsStart another consumer in another window to see pytest-kafkavent messages for failed tests only./kafka-console-consumer.sh --bootstrap-server $KV_BOOTSTRAP_SERVER \
    --consumer.config ../config/app-services.properties --from-beginning --topic kafkavents-failedRun the example pytest test scriptspytest example_tests/ --junitxml=/tmp/kafkavent.xml --kv-topics my-other-topic
    pytest example_tests/ -q --kv-conf examples/kafka_conf.json \
    --kv-topics kafkavent --kv-topics-failed kafkavent-failedOr just pull the container fromQuay.io:-)TODO: create a container with all of this goodness in it, upload to Quay.io, and link hereUse the test generator...pytest example_tests/ --kv-conf examples/kafka_conf.json \
--kv-topics kafkavent --kv-topics-failed kafkavent-failed \
--kv-eventlog=/tmp/kafkavent.log -k test_kafkavents --kv-test 4,1,1,1
Package: pytest-kasima
pytest-kasimainstallpip install pytest-kasimaIf you're a fan ofrich library, can integratepip install pytest-kasima[rich]usageDisplay horizontal lines above and below the captured standard output for easy viewing.--capture=noor-soption is not required.options--kasima-skip- If you don't like this plugin, disable it :smiley:--kasima-rich-skip- Skip the rich integration
Package: pytest-keep-together
pytest-keep-togetherPytest plugin to customize test ordering by running all "related" tests together.UsageTBDInstallationCreate a new virtual environment, activate it and install development requirements:pip install requirements_dev.txtDevelopment best-practicesEvery commit must be checked with flake8 and mypy:flake8mypy .Build and distribute a new versionBuild packagepy -m buildPublish new version to test PyPipy -m twine upload --repository testpypi dist/*Publish new version to PyPi (production)py -m twine upload dist/*