Saravanan666/pypi-org huggingface dataset:
Package: pytest-helpers-namespace
Pytest Helpers NamespaceThis plugin does not provide any helpers topytest, it does, however,
provide a helpers namespace inpytestwhich enables you to register helper
functions in yourconftest.pyto be used within your tests without having
to import them.FeaturesProvides ahelperspytestnamespace which can be used to register
helper functions without requiring you to import them on your actual tests to
use them.RequirementsNone!InstallationYou can install “pytest-helpers-namespace” viapipfromPyPI:$ pip install pytest-helpers-namespaceUsageConsider the followingconftest.pyfile:importpytest@pytest.helpers.registerdeffoo(bar):"""
    this dumb helper function will just return what you pass to it
    """returnbarAnd now consider the following test case:deftest_helper_namespace():assertpytest.helpers.foo(True)isTruePretty simple right?!You can even nest namespaces. Consider the followingconftest.pyfile:pytest_plugins=["helpers_namespace"]importpytest@pytest.helpers.can.haz.registerdeffoo(bar):"""
    this dumb helper function will just return what you pass to it
    """returnbarAnd now consider the following test case:deftest_helper_namespace():assertpytest.helpers.can.haz.foo(True)isTrueYou can even pass a name to the register function and that will be the helper function name.ThisPytestplugin was generated withCookiecutteralong with@hackebrot’sCookiecutter-pytest-plugintemplate.DocumentationThe full documentation can be seenhere.
Package: pytest-homeassistant
A pytest plugin for use with Home Assistant custom components.Thispytestplugin provides several pytest fixtures and utils to make testingHome Assistantcustom components easier.The plugin allows you to use a subset of fixtures and helpers from theHome Assistanttest code to allow you to test your own custom components.FeaturesFixtureshass- Used to mock a hass instance.  This is primarily useful in testing yourconfig_flowcode.  Examples of it’s usage can be found in the Home Assistant
tests.fromcustom_components.steam_wishlistimportconfig_flowasyncdeftest_flow_init(hass):"""Test the initial flow."""result=awaithass.config_entries.flow.async_init(config_flow.DOMAIN,context={"source":"user"})expected={"data_schema":config_flow.DATA_SCHEMA,"description_placeholders":None,"errors":{},"flow_id":mock.ANY,"handler":"steam_wishlist","step_id":"user","type":"form",}assertexpected==resultaioclient_mock- Used to mock responses fromhomeassistant.helpers.aiohttp_client.async_get_clientsessionin your test code.You can find example usage of both of these fixtures in theHome Assistant testsdirectory.Helperspytest_homeassistant.async_mock- Contains all mock methods that can handle
async calls.frompytest_homeassistant.async_mockimportAsyncMockfromcustom_components.steam_wishlistimportsensor_managerasyncdeftest_sensormanager_async_register_component(hass,coordinator_mock):"""Test that we add listeners and referesh data if all platforms were registered."""manager=sensor_manager.SensorManager(hass,url="http://fake.com")mock_async_add_entities=AsyncMock()awaitmanager.async_register_component("sensor",mock_async_add_entities)assertmock_async_add_entities.calledisTrueRequirementshomeassistantInstallationYou can install “pytest-homeassistant” viapipfromPyPI:$ pip install pytest-homeassistantContributingContributions are very welcome.  I only incldued fixtures and test helpers that
were useful to me when testing my custom components.  If there are others that would
be useful to you, pull requests are welcome!LicenseDistributed under the terms of theMITlicense, “pytest-homeassistant” is free and open source software.IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-homeassistant-custom-component
pytest-homeassistant-custom-componentPackage to automatically extract testing plugins from Home Assistant for custom component testing.
The goal is to provide the same functionality as the tests in home-assistant/core.
pytest-homeassistant-custom-component is updated daily according to the latest homeassistant release including beta.Usage:All pytest fixtures can be used as normal, likehassFor helpers:home-assistant/core native test:from tests.common import MockConfigEntrycustom component test:from pytest_homeassistant_custom_component.common import MockConfigEntryIf your integration is inside acustom_componentsfolder, acustom_components/__init__.pyfile or changes tosys.pathmay be required.enable_custom_integrationsfixture is required (versions >=2021.6.0b0)Some fixtures, e.g.recorder_mock, need to be initialized beforeenable_custom_integrations. Seehttps://github.com/MatthewFlamm/pytest-homeassistant-custom-component/issues/132.pytest-asyncio might now requireasyncio_mode = autoconfig, see #129.If usingload_fixture, the files need to be in afixturesfolder colocated with the tests. For example, a test intest_sensor.pycan load data fromsome_data.jsonusingload_fixturefrom this structure:tests/
   fixtures/
      some_data.json
   test_sensor.pyExamples:Seelist of custom componentsas examples that use this package.Also see tests forsimple_integrationin this repository.Usecookiecutter-homeassistant-custom-componentto create a custom component with tests by usingcookiecutter.Thegithub-custom-component-tutorialexplaining in details how to create a custom componenent with a test suite using this package.More InfoThis repository is set up to be nearly fully automatic.Version of home-assistant/core is given inha_version,pytest_homeassistant_custom_component.const, and in the README above.This package is generated against published releases of homeassistant and updated daily.PRs should not include changes to thepytest_homeassistant_custom_componentfiles.  CI testing will automatically generate the new files.Version StrategyWhen changes in extraction are required, there will be a change in the minor version.A change in the patch version indicates that it was an automatic update with a homeassistant version.This enables tracking back to which versions of pytest-homeassistant-custom-component can be used for
extracting testing utilities from which version of homeassistant.This package was inspired bypytest-homeassistantby @boralyl, but is intended to more closely and automatically track the home-assistant/core library.
Package: pytest-honey
A simple plugin to use with pytestThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesAdds--honeyoption that:turnsFtoHONEYwith-v, turnsFAILUREtoHONEY for bread.Requirementspytest >=3.5.0InstallationYou can install “pytest-honey” viapipfromPyPI:$ pip install pytest-honeyUsage$ pytest –honeyContributingContributions 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-honey” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-hot-test
A plugin that tracks test changesThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-hot-test” viapipfromPyPI:$ pip install pytest-hot-testUsageTODOContributingContributions 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-hot-test” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-html-object-storage
pytest-html-object-storagePytest report plugin for send HTML report on object-storageAllow to send HTML report on object-storage.ImplementationsMinIO(tested with Scaleway)Swift(tested with OVH)installationpip install pytest-html-object-storageConfigure via env varCommonOBJECT_STORAGE_ENDPOINT="localhost:9000"
OBJECT_STORAGE_BUCKET="bucket"
OBJECT_STORAGE_USERNAME="admin"
OBJECT_STORAGE_PASSWORD="password"
OBJECT_STORAGE_REGION_NAME=""Common OptionalOBJECT_STORAGE_POLICY="private" // public-read
OBJECT_STORAGE_RETENTION="30" // day unitSpecific MinIOOptionalOBJECT_STORAGE_SECURE="false"
OBJECT_STORAGE_PROVIDER="default" // scalewaySpecific SwiftOBJECT_STORAGE_TENANT_ID=""
OBJECT_STORAGE_TENANT_NAME=""Add option to send HTML reportMinIOpytest --store-minioSwiftpytest --store-swiftDevChange versioneditpytest_html_object_storage/__init__.pycommitgit commit -m "v0.1.0"taggit tag v0.1.0Build packagepython -m build
twine upload dist/*
Package: pytest-html-reporter
Generates a static html report based onpytestframeworkFeaturesGeneric informationOverviewTrendsSuite HighlightsTest suite detailsArchives / HistoryScreenshots on failureTest Rerun supportInstallation$pip3installpytest-html-reporterUsageBy default, the filename used ispytest_html_reporter.htmland path chosen isreport; you can skip both or
either one of them if not needed:$ pytest tests/Custom path, filename, and titleAdd--html-reporttag followed by path location and filename to customize the report location and filename:$ pytest tests/ --html-report=./report
$ pytest tests/ --html-report=./report/report.htmlAdd--titletag followed by the report title:$ pytest tests/ --html-report=./report --title='PYTEST REPORT'pytest.iniAlternate option is to add this snippet in thepytest.inifile:[pytest]
addopts = -vs -rf --html-report=./report --title='PYTEST REPORT'Note:If you fail to provide--html-reporttag, it consider your project’s home directory as the basescreenshots on failureImportattachfrom the library and call it with the selenium command as given below:from pytest_html_reporter import attach

...
attach(data=self.driver.get_screenshot_as_png())Is there a demo available for this gem?Yes, you can use this demo as an example,https://github.com/prashanth-sams/pytest-html-reporter:$ pytest tests/functional/
Package: pytest-httpbin
httpbin is an amazing web service for testing HTTP libraries. It has several
great endpoints that can test pretty much everything you need in a HTTP
library. The only problem is: maybe you don’t want to wait for your tests to
travel across the Internet and back to make assertions against a remote web
service.Enter pytest-httpbin. Pytest-httpbin creates a pytest “fixture” that is
dependency-injected into your tests. It automatically starts up a HTTP server
in a separate thread running httpbin and provides your test with the URL in the
fixture. Check out this example:deftest_that_my_library_works_kinda_ok(httpbin):assertrequests.get(httpbin.url+'/get/').status_code==200This replaces a test that might have looked like this before:deftest_that_my_library_works_kinda_ok():assertrequests.get('http://httpbin.org/get').status_code==200pytest-httpbin also supports https and includes its own CA cert you can use.
Check outthe full documentationon the github page.
Package: pytest-httpdbg
pytest-httpdbgA pytest plugin to record HTTP(S) requests with stack trace.installationpip install pytest-httpdbgusagepytest custom options--httpdbg             record HTTP(S) requests
  --httpdbg-dir=HTTPDBG_DIR
                        save httpdbg traces in a directory
  --httpdbg-no-clean    do not clean the httpdbg directory
  --httpdbg-initiator=HTTPDBG_INITIATOR
                        add a new initiator (package) for httpdbgoption httpdbgEnables the record of the HTTP requests.option httpdbg-dirIndicates where to save the log files.option httpdbg-no-cleanDoes not clean existing log files if the log directory is not empty.option http-initiatorAn initiator is the function/method that is at the origin of the HTTP requests. By default, we already support some packages but you can add your own initiators.To add a new package in the list of initiators, you can use thehttp-initiatorcommand line argument.You can use any package as an initiator, this is not limited to HTTP requests.test reportWhen the test is finished (teardown step included), one log file in markdown format is written. The path to this log file is stashed in the item when the test starts (before the setup step), even if the file not exists yet.pytest-htmlYou can copy the following code in your top-levelconftest.pyto include the logs into your pytest-html report.importosimportpytestfrompytest_httpdbgimporthttpdbg_record_filename@pytest.hookimpl(hookwrapper=True)defpytest_runtest_makereport(item,call):pytest_html=item.config.pluginmanager.getplugin("html")outcome=yieldreport=outcome.get_result()extras=getattr(report,"extras",[])ifcall.when=="call":ifhttpdbg_record_filenameinitem.stash:extras.append(pytest_html.extras.url(os.path.basename(item.stash[httpdbg_record_filename]),name="HTTPDBG",))report.extras=extrasThis example works if you use the same directory for the html test report file and the httpdbg logs.pytest demo/ --httpdbg --httpdbg-dir report  --html=report/report.htmlIf this is not the case, you must adapt it to your configuration.documentationhttps://httpdbg.readthedocs.io/en/latest/pytest/
Package: pytest-httpretty
# pytest-httpretty - A thin wrapper of HTTPretty for pytestpytest-httpretty provides `httpretty` marker and `stub_get()` shorthand function.```pythonimport httprettyimport pytestimport requestsfrom pytest_httpretty import stub_get@pytest.mark.httprettydef test_mark_httpretty():httpretty.register_uri(httpretty.GET, 'http://example.com/', body='Hello')assert requests.get('http://example.com').text == 'Hello'@pytest.mark.httprettydef test_stub_get():stub_get('http://example.com/', body='World!')assert requests.get('http://example.com').text == 'World!'```
Package: pytest-httptesting
HTTP_TESTINGDescriptionThis project aims to help to create e2e tests, by chaining http calls and verifications on target pages.ConceptThis project is built on pytest.Each .py file in test represents several tests scenario on one target site, we can provide the site's hostname
as a local variable, the framework know how to construct http call from that.Each test function in the .py test file represent a scenario of test which is consisted by several steps. For example,
test user's account page, first, we authenticate the client by post user's name and password,
then access the account page to verify some values. Each step is described by calling the variablecheckwhich is a pytest fixture.TutorialInstallpipinstallpytest-httptestingCreate test suite# test/test_example.pyfromhttp_testing.assertionsimportAssertions,NegativeAssertionsfromhttp_testing.cookieimportCookiefromhttp_testing.page_checkerimportPageCheckerfromhttp_testing.validatorsimportRegexhost="www.google.com"# mandatory: used in the `check` fixturescheme="https"# "https" by defaultport=None# None by defaultdeftest_scenario_one(check:PageChecker):check(title="Senario One",path="/",should_find=Assertions(status_code=200,content=["<title>Google</title>"],headers={"Content-Type":"text/html; charset=ISO-8859-1"},cookies=[Cookie(name="AEC",value=Regex(r".*"))],),should_not_find=NegativeAssertions(status_code=400,content=["groot"],headers={"nooooo":""},cookies=[Cookie(name="nop",value="a")],),timeout=10,# you can pass additional kwargs to httpx request)assertcheck.previous_response.status_code==200# inspect previous responseRun test$pytesttest--tb=no--no-header-v# traceback is disabled because it is not very useful to anayse the functional error=============testsessionstarts=============collected1item

test/test_example.py::test_scenario_onePASSED=============1passedin0.16s=============DebugIn case of error, a temporary file will be generated, as shown in theshort test summary info. It is a json file concluding
response content, status code, headers and cookies.$pytesttest--tb=no--no-header-v=============testsessionstarts=============collected1item

test/test_example.py::test_scenario_oneFAILED=============shorttestsummaryinfo=============FAILEDtest/test_example.py::test_scenario_one-AssertionError:SenarioOne-'Content-Typessss':'text/html; charset=ISO-8859-1'notfoundinheadersonpage'https://www.google.com/'-pleasecheckfile'/tmp/tmptaowd2u5'=============1failedin1.22s=============AdvancedCustomize the http client configurationIt is possible to create a fixturehttp_clientto create your own http client.@pytest.fixturedefhttp_client():withClient(verify=False,cookies={"cookie_1":"cookie_value_1"})asclient:yieldclientCustomize the base urlIt is possible to create a fixturebase_urlto override the default construction of base url.fromhttpximportURL@pytest.fixturedefbase_url()->URL:returnURL("https://www.google.com")
Package: pytest-httpx-blockage
pytest-httpx-blockagePackage disables requests during pytest execution forHTTPXIf request occurs,RequestBlockageExceptionwill be raised.InstallationInstallpytest-httpx-blockage(or download from PyPI):pipinstallpytest-httpx-blockagePass param--blockage-httpxto enable blockage.ConfigurationBy default, blockage will be disabled in tests marked asintegration.
You can override it using--disable-blockage-mark=new_mark.All settings can be stored in your.cfgfile, with the same variable names as
the argument names mentioned under usage:blockage-httpx=true
disable-blockage-mark=new_mark
Package: pytest-httpx-recorder
pytest_httpx_recorderRecorder feature based on pytest_httpx, like recorder feature in responsesInstallationpipinstallpytest_httpx_recorderFor more information about installation, you can refer
toInstallation.Record the Requestsimporthttpxfrompytest_httpx_recorder.recorderimportResRecorderif__name__=='__main__':recorder=ResRecorder()withrecorder.record():client=httpx.Client(follow_redirects=True)client.get('https://danbooru.donmai.us/artists/167715.json')client.head('https://cdn.donmai.us/original/9b/25/__akisato_konoha_uehara_meiko_shimoda_kaori_yamada_touya_rokuta_mamoru_and_4_more_comic_party_and_1_more__9b257058ee0866d554d01e9036ecb3b6.jpg')# save to directory 'test_danbooru_simple'recorder.to_resset().save('test_danbooru_simple')Replay in Pytestimporthttpximportpytestfrompytest_httpx_recorder.recorderimportResSet@pytest.fixturedefreplay_from_test_danbooru_simple(httpx_mock):resset=ResSet.load('test_danbooru_simple')withresset.mock_context(httpx_mock):yielddeftest_replay(replay_from_test_danbooru_simple):client=httpx.Client(follow_redirects=True)resp=client.get('https://danbooru.donmai.us/artists/167715.json')resp.raise_for_status()resp=client.head('https://cdn.donmai.us/original/9b/25/__akisato_konoha_uehara_meiko_shimoda_kaori_yamada_touya_rokuta_mamoru_and_4_more_comic_party_and_1_more__9b257058ee0866d554d01e9036ecb3b6.jpg')resp.raise_for_status()
Package: pytest-hue
# pytest-hue
Control your Phillips Hue by PyTest.The following parameters are used:Brightness is controlled by the number of run tests against total number of testsGreen hue is controlled by the number of passed tests against total number of testsRed hue is controlled by the number of failed tests against total number of testsBlue hue is controlled by the number of passed tests against total number of tests## Configuration
You’ll need to supply the following values:–hue-ip: Hue Bridge IP Address–hue-username: Username to connect to Hue Bridge with ([follow instructions here to get a new one](https://developers.meethue.com/develop/get-started-2/))–hue-rooms: Rooms to control the lights within## Installing and Running
To installpip install pytest-hueor clone this repo and runpython setup.py installTo run, make sure:Your Phillips Hue Bridge and lights are turned onThen run with following command (substituting the appropriate values)pytest –hue-ip XXX.XXX.XXX.XXX –hue-username XXXXXXXXXX –hue-rooms Office
Package: pytest-iam
pytest-iampytest-iam spawns a lightweight OAuth2 / OpenID Server (OIDC) in a thread to be used in your test suite.
The machinery involvesCanailleandAuthlib.RepositoryPackageDocumentationInstallationpip install pytest-iamUsagepytest-iam provides tools to test your application authentication mechanism agaist a OAuth2/OIDC server:It launches aCanailleinstanceIt provides aiam_serverfixture that comes with several features:the URL of the IAM server to configure your applicationIAM models (Users, groups, clients, tokens etc.) to prepare your tests and check the side effects.
More details onthe referenceutilities to log-in users and give their consent to your applicationutilities to generate random users and groupsTo run a full authentication process for a client application in your test,
you can write something like this:deftest_authentication(iam_server,testapp,client):# create a random user on the IAM serveruser=iam_server.random_user()# logs the user in give its consent to your applicationiam_server.login(user)iam_server.consent(user)# simulate an attempt to access a protected page of your appresponse=testapp.get("/protected",status=302)# get an authorization code request at the IAMres=requests.get(res.location,allow_redirects=False)# access to the redirection URIres=testclient.get(res.headers["Location"])res.mustcontain("Hello World!")Check theclient applicationorresource servertutorials
for more usecases.
Package: pytest-ibutsu
This is a plugin that will report test rests from pytest to anIbutsu server.RequirementsPython 3.8+pytestattrsInstallationInstall the plugin viapip:pip install pytest-ibutsuIf you’re developing this plugin, you can create an editable installation:pip install -e .Getting startedTo push your results to the Ibutsu server, use the--ibutsuoption with the URL to your server:pytest --ibutsu http://ibutsu/AuthenticationTo authenticate against your Ibutsu server, use the--ibutsu-tokenoption with a token from your
Ibutsu server. Go to your profile page, select tokens, and generate a token there. Copy and paste
the JWT token generated into this option:pytest --ibutsu http://ibutsu/ --ibutsu-token eyJhbGci.......CA1opEQMore optionsTo set the source for the test results, use the--ibutsu-sourceoption:pytest --ibutsu http://ibutsu/ --ibutsu-source my-test-runIf you want to add metadata to each result’s metadata, you can use the--ibutsu-dataoption:pytest --ibutsu http://ibutsu/ --ibutsu-data key=valueYou can specify multiple of this option:pytest --ibutsu http://ibutsu/ --ibutsu-data key1=value1 --ibutsu-data key2=value2You can also specify sub-keys via dotted notation:pytest --ibutsu http://ibutsu/ --ibutsu-data key.subkey.susbsub=valueIf you need to accumulate data from multiplepytestsessions, you should provide the same UUID
intoibutsu-run-idoption:pytest --ibutsu-run-id=<UUID string>

pytest --ibutsu-run-id=<the same UUID string>The archive will be rebuilt and the data on the Ibutsu server will be updated.Set projectIf your Ibutsu server requires a project set, you can do that with the--ibutsu-projectoption:pytest --ibutsu http://ibutsu/ --ibutsu-project 5eb1aff37c274bcd20002476You can also use the projectnamefield:pytest --ibutsu http://ibutsu/ --ibutsu-project my-projectOffline usageIf you want to still store your results, but can’t upload immediately, the Ibutsu plugin can create
an archive which you can upload later. Usearchivewith the--ibutsuoption:pytest --ibutsu archiveThe Ibutsu plugin will save the archive in your current directory, and will print out the location.UsageWith this plugin installed, and the configuration set up, your test results will automatically be
sent to the Ibutsu server.HooksThe plugin has its own hooks. They are defined innewhooks.py.