Saravanan666/pypi-org huggingface dataset:
Package: pytest-keyring
pytest-keyringPytest plugin to access any configured keyring using thekeyringpackage.MotivationFrequently, tests require access to services, like databases, REST APIs, or blob storages. These services are sometimes hard or impossibel to mock or reproduce in a test environment. In particular, functional or end-to-end tests will be inclined to interact with real instances of these services. Accessing these services can require credentials, and using the keyring can be an alternative to populating CI environment variables with credentials.InstallationInstall with:python-mpipinstallpytest-keyringPython versions 3.8 to 3.12 are supported.UsageAccessing credentials in keyringAny test arguments whose names match the prefixes configured by--keyring-password-prefixand--keyring-credential-prefix("password"and"credential"by default) will be replaced by the corresponding password or credential, respectively:deftest_with_database(credential_postgres_dbuser):client=connect(username=credential_postgres_dbuser.username,password=credential_postgres_dbuser.password)...When collecting the test, thecredential_postgres_dbuserinstructspytest-keyringto fetch the credential for the "postgres" service and the "dbuser" username, by making the following call tokeyring.get_credential:keyring.get_credential("postgres","dbuser")Configuring a keyring backendThe--keyring-backendconfiguration flag can be used to specify a keyring backend. For example, setting the null keyring backend:pytest--keyring-backend=keyring.backends.null.KeyringCauses all credentials and passwords to beNone:deftest_with_null_backend(credential_postgres_dbuser,password_postgres_dbuser):assertcredential_postgres_dbuserisNoneassertpassword_postgres_dbuserisNone...
Package: pytest-kind
pytest-kindTest your Python Kubernetes app/operator end-to-end withkindandpytest.pytest-kindis a plugin for pytest which provides thekind_clusterfixture.
The fixture will install kind 0.17.0, create a Kubernetes 1.25 cluster, and provide convenience functionality such as port forwarding.UsageInstallpytest-kindvia pip or viapoetry, e.g.:poetry add --dev pytest-kindWrite your pytest functions and use the providedkind_clusterfixture, e.g.:deftest_kubernetes_version(kind_cluster):assertkind_cluster.api.version==('1','25')To load your custom Docker image and apply deployment manifests:importrequestsfrompykubeimportPoddeftest_myapp(kind_cluster):kind_cluster.load_docker_image("myapp")kind_cluster.kubectl("apply","-f","deployment.yaml")kind_cluster.kubectl("rollout","status","deployment/myapp")# using Pykube to query podsforpodinPod.objects(kind_cluster.api).filter(selector="app=myapp"):assert"Sucessfully started"inpod.logs()withkind_cluster.port_forward("service/myapp",80)asport:r=requests.get(f"http://localhost:{port}/hello/world")r.raise_for_status()assertr.text=="Hello world!"See theexamplesdirectory for sample projects and also check outkube-web-viewwhich uses pytest-kind for its e2e tests.KindCluster objectThekind_clusterfixture is an instance of the KindCluster class with the following methods:load_docker_image(docker_image): load the specified Docker image into the kind clusterkubectl(*args): run thekubectlbinary against the cluster with the specified arguments. Returns the process output as string.port_forward(service_or_pod_name, remote_port, *args): run "kubectl port-forward" for the given service/pod and return the (random) local port. To be used as context manager ("with" statement). Pass the namespace as additional args to kubectl via "-n", "mynamespace".KindCluster has the following attributes:name: the kind cluster namekubeconfig_path: the path to the Kubeconfig file to access the clusterkind_path: path to thekindbinarykubectl_path: path to thekubectlbinaryapi:pykubeHTTPClient instance to access the cluster from PythonYou can also use KindCluster directly without pytest:frompytest_kindimportKindClustercluster=KindCluster("myclustername")cluster.create()cluster.kubectl("apply","-f","..")# ...cluster.delete()Pytest OptionsThe kind cluster name can be set via the--cluster-nameCLI option.The kind cluster is deleted after each pytest session, you can keep the cluster by passing--keep-clusterto pytest.Note that you can use thePYTEST_ADDOPTSenvironment variable to pass these options to pytest. This also works if you call pytest from a Makefile:# for test debugging: don't delete the kind clusterPYTEST_ADDOPTS=--keep-clustermaketestNotesThekind_clusterfixture is session-scoped, i.e. the same cluster will be used across all test modules/functions.Thekindandkubectlbinaries will be downloaded once to the local directory./.pytest-kind/{cluster-name}/. You can use them to interact with the cluster (e.g. when--keep-clusteris used).Some cluster pods might not be ready immediately (e.g. kind's CoreDNS take a moment), add wait/poll functionality as required to make your tests predictable.
Package: pytest-konira
This plugin allows you to collect and execute Konira test cases as you would
normally do with Konira’s own test runner but with the extra functionality that
comes with the awesome py.testOnce the plugin is installed you get a single entry in thepy.testhelp
menu giving you the option to add the--koniraflag to collect cases.Project page is at:http://github.com/alfredodeza/pytest-koniraThe actual Konira project can be found at:http://konira.cafepais.com
Package: pytest-koopmans
A plugin for testing the koopmans packageThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-koopmans” viapipfromPyPI:$ pip install pytest-koopmansUsageTODOContributingContributions 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 theGNU GPL v3.0license, “pytest-koopmans” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-krtech-common
================================Krtech common library for pytest================================Selenium web elements wrapper library based on allure report.Contains base elements, pages and methods (steps).------------Installation------------You can install using pip:::pip install pytest-krtech-common-------------Configuration-------------To configure ``conftest.py`` do:code:: pythonimport pytestfrom configuration import TestConfig, ConftestOptionsclass OverwrittenTestConfig(TestConfig):myprop = "myprop_value"mysqldb = "mydb"tc = OverwrittenTestConfig()c = ConftestOptions(tc)def pytest_addoption(parser):c.pytest_addoption(parser)@pytest.mark.tryfirstdef pytest_runtest_makereport(item, call, __multicall__):return c.pytest_runtest_makereport(item, call, __multicall__)@pytest.yield_fixture(scope='session')def config(request):op = c.config(request)yield opop.driver.close()-----Usage-----Pages:code:: pythonfrom selenium.webdriver.common.by import Byfrom krtech.decorators import pagefrom krtech.elements.base_element import BaseElementfrom krtech.pages.base_page import BasePage@page('Profile Page', By.ID, 'profilePageId')class ProfilePage(BasePage):HEADER = BaseElement("Profile page header", By.XPATH, ".//h6")Tests:code:: pythonfrom youproject.pages.profile_page import ProfilePagefrom krtech.steps.user_steps import UserSteps@pytest.mark.usefixtures('config')@allure.feature('Profile Header')class TestProfile:def test_profile_header(self, config):user = UserSteps(config)profile_page = ProfilePage(config)user.opens('/profile')user.should_see_element_matched_to(profile_page.PROFILE, equal_to_ignoring_case(c.customers_data.name))user.should_see_attribute_value(profile_page.OTHER, 'disabled', True)-------------Wheel package-------------To build a wheel package do::cd pytest-krtech-common/python setup.py bdist_wheelPackage should be available at::dist/pytest_krtech_common-0.1-py3-none-any.whlTo install from wheel do::pip install pytest_krtech_common-0.1-py3-none-any.whl
Package: pytest-kuunda
pytest plugin to help with test data setup for PySpark testsThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-kuunda” viapipfromPyPI:$ pip install pytest-kuundaUsageTODOContributingContributions 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-kuunda” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-kwparametrize
Alternate syntax for@pytest.mark.parametrizewith test cases as dictionaries
and default value fallbacks.The problemTests parametrized using@pytest.mark.parametrizecan easily become hard to read
when the number of parameters grows large. For example:@pytest.mark.parametrize(
    "a, b, c, d, e, f, expect",
    [
        (3, "one", 4.0, 0x01, 0o5, 9e0, 0b10,),
        (6, "five", 3.0, 0x05, 0o10, 9e0, 0b111,),
    ],
)
def test_my_func(a, b, c, d, e, f, expect):
    assert my_func(a, b, c, d, e, f) == expectThe solutionpytest-kwparametrizeuses dictionaries instead of tuples for test cases.
This way every parameter is always labeled and more easily identified by the reader.
Also, test function parameters aren’t declared separately
as with@pytest.mark.parametrize,
and test cases don’t need to be enclosed in a list:@pytest.mark.kwparametrize(
    dict(a=3, b="one", c=4.0, d=0x01, e=0o5, f=9e0, expect=0b10,),
    dict(a=6, b="five", c=3.0, d=0x05, e=0o10, f=9e0, expect=0b111,),
)
def test_my_func(a, b, c, d, e, f, expect):
    assert my_func(a, b, c, d, e, f) == expectSee examples below for additional features.ExamplesBasic syntax with no default values:@pytest.mark.kwparametrize(
    dict(a=0, b=0, expect=0),
    dict(a=1, b=0, expect=1),
)
def test_my_func(a, b, expect):
    assert my_func(a, b) == expectDefining a default value for a parameter so it can be omitted from test cases:@pytest.mark.kwparametrize(
    dict(a=0, expect=0),
    dict(a=1, expect=1),
    dict(a=0, b=1, expect=0),
    dict(a=1, b=1, expect=2),
    b=0,
)
def test_my_func(a, b, expect):
    assert my_func(a, b) == expectYou can also provide the test cases as an iterable (e.g. list, tuple, generator)
just as with@pytest.mark.parametrize:@pytest.mark.kwparametrize(
    [
        dict(a=0, b=0, expect=0),
        dict(a=1, b=0, expect=1),
    ]
)
def test_my_func(a, b, expect):
    assert my_func(a, b) == expectDefault values can also be paassed as a dictionary
using thedefaults=keyword argument
(here all parameters have a default):@pytest.mark.kwparametrize(
    dict(),
    dict(a=1, expect=1),
    dict(b=1),
    dict(a=1, b=1, expect=2),
    defaults=dict(a=0, b=0, expect=0),
)
def test_my_func(a, b, expect):
    assert my_func(a, b) == expectThe marker works with fixtures and Pytest’s built-in keyword arguments:@pytest.mark.kwparametrize(
    # test cases:
    dict(),
    dict(filename="special.txt", expect=1),
    dict(content="special content"),

    # default parameter values:
    filename="dummy.txt",
    content="dummy content",
    expect=42,

    # example of a Pytest built-in keyword argument:
    ids=["with defaults", "special filename", "speial content"],
)
def test_my_func(tmpdir, filename, content, expect):
    filepath = (tmpdir / filename)
    filepath.write(content)
    assert my_func(filepath) == expectContributors ✨SeeREADME.rstfor the list of contributors.This project follows theall-contributorsspecification.
Contributions of any kind are welcome!
Package: pytest-langchain
🦜️🔗✅ pytest-langchainPytest-style test runner for langchain projects.InstallationInstall from PyPI:pip install pytest-langchainInstall from source:git clone https://github.com/ajndkr/pytest-langchain
cd pytest-langchain
pip install .UsageSerialise your LLM chain into a YAML file.
Refer todocsfor more details.Create a new configuration YAML file to runpytest-langchainwith the following structure:chain_file:<path to chain YAML file>test_cases:-[<input-1>,<expected output-1>]-[<input-2>,<expected output-2>]-...Runpytest-langchain:pytest-langchain -c <path to config YAML file> --openai-api-key <OPENAI API key>For more options, runpytest-langchain --help.
Package: pytest-lark
pytest-larkInstallingInstall and update using pip:$ pip install -U pytest-larkA Simple Exampleimportpytest_larkLinksDocumentation:https://github.com/MarkHoo/pytest-larkPyPI Releases:https://pypi.org/project/pytest-lark/Source Code:https://github.com/MarkHoo/pytest-larkIssue Tracker:https://github.com/MarkHoo/pytest-lark/issuesWebsite:https://pypi.org/project/pytest-lark/
Package: pytest-layab
pytest fixtures and assertions functions for layabpytestfixtures and utility functions that can be used to testlayabbased REST API.Flask based APITest clientSending JSON (as POST)Sending file (as POST)Sending JSON (as PUT)Assert CREATED responseCompare response content to a fileFlaskTest clientYou can have access to thepytest-flaskclientfixture for yourlayabbased REST API.Providing aservice_module_namepytestfixture will give you access to aFlask test clientand ensureSERVER_ENVIRONMENTenvironment variable will be set totestin order to load test specific configuration.pytest-flaskmust be installed for the following sample to work:importpytestfrompytest_layab.flaskimportapp@pytest.fixturedefservice_module_name():# Considering main.py exists within a folder named my_module.# And main.py contains a variable named application containing the Flask app.return"my_module.main"deftest_get(client):# Perform a GET request on your application on /my_endpoint endpoint.response=client.get('/my_endpoint')Helper functionsThe following examples consider that you already have atest client.Posting JSONfrompytest_layab.flaskimportpost_jsondeftest_json_post(client):response=post_json(client,'/my_endpoint',{'my_key':'my_value',})Posting filefrompytest_layab.flaskimportpost_filedeftest_file_post(client):response=post_file(client,'/my_endpoint','file_name','file/path')Putting JSONfrompytest_layab.flaskimportput_jsondeftest_json_put(client):response=put_json(client,'/my_endpoint',{'my_key':'my_value',})Checking HTTP 201 (CREATED) responsepytest_layab.flask.assert_201function will ensure that the status code of the response is 201 and that thelocationheader contains the expected relative route.frompytest_layab.flaskimportassert_201deftest_created_response(client):response=Noneassert_201(response,'/my_new_location')Checking response contentpytest_layab.flask.assert_filefunction will ensure that the response body will have the same content as in the provided file.frompytest_layab.flaskimportassert_filedeftest_with_content_in_a_file(client):response=Noneassert_file(response,'path/to/file/with/expected/content')MocksDate-TimeYou can mock current date-time.importdatetimeimportmodule_where_datetime_is_used_date_time_for_tests=datetime.datetime(2018,10,11,15,5,5,663979)classDateTimeModuleMock:classDateTimeMock(datetime.datetime):@classmethoddefnow(cls,tz=None):return_date_time_for_tests.replace(tzinfo=tz)classDateMock(datetime.date):@classmethoddeftoday(cls):return_date_time_for_tests.date()timedelta=datetime.timedeltatimezone=datetime.timezonedatetime=DateTimeMockdate=DateMockdeftest_date_mock(monkeypatch):monkeypatch.setattr(module_where_datetime_is_used,"datetime",DateTimeModuleMock)How to installpython 3.6+must be installedUse pip to install module:python-mpipinstallpytest_layab
Package: pytest-lazy-fixture
Use your fixtures in@pytest.mark.parametrize.Installationpipinstallpytest-lazy-fixtureUsageimportpytest@pytest.fixture(params=[1,2])defone(request):returnrequest.param@pytest.mark.parametrize('arg1,arg2',[('val1',pytest.lazy_fixture('one')),])deftest_func(arg1,arg2):assertarg2in[1,2]Also you can use it as a parameter in@pytest.fixture:importpytest@pytest.fixture(params=[pytest.lazy_fixture('one'),pytest.lazy_fixture('two')])defsome(request):returnrequest.param@pytest.fixturedefone():return1@pytest.fixturedeftwo():return2deftest_func(some):assertsomein[1,2]Please seetestsfor more examples.ContributingContributions are very welcome. Tests can be run withtox.LicenseDistributed under the terms of theMITlicense,pytest-lazy-fixtureis free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a
detailed description.
Package: pytest-lazy-fixtures
pytest-lazy-fixturesUse your fixtures in@pytest.mark.parametrize.This project was inspired bypytest-lazy-fixture.Improvements that have been made in this project:You can use fixtures in any data structuresYou can access the attributes of fixturesYou can use functions in fixturesInstallationpipinstallpytest-lazy-fixturesUsageTo use your fixtures inside@pytest.mark.parametrizeyou can uself(lazy_fixture).importpytestfrompytest_lazy_fixturesimportlf@pytest.fixture()defone():return1@pytest.mark.parametrize('arg1,arg2',[('val1',lf('one'))])deftest_func(arg1,arg2):assertarg2==1lfcan be used with any data structures. For example, in the following example,lfis used in the dictionary:importpytestfrompytest_lazy_fixturesimportlf@pytest.fixture()defone():return1@pytest.mark.parametrize('arg1,arg2',[('val1',{"value":lf('one')})])deftest_func(arg1,arg2):assertarg2=={"value":1}You can also specify getting an attribute through a dot:importpytestfrompytest_lazy_fixturesimportlfclassEntity:def__init__(self,value):self.value=value@pytest.fixture()defone():returnEntity(1)@pytest.mark.parametrize('arg1,arg2',[('val1',lf('one.value'))])deftest_func(arg1,arg2):assertarg2==1And there is some useful wrapper calledlfc(lazy_fixture_callable). It can work with any callable and your fixtures, e.g.importpytestfrompytest_lazy_fixturesimportlfclassEntity:def__init__(self,value):self.value=valuedef__str__(self)->str:returnstr(self.value)defsum(self,value:int)->int:returnself.value+value@pytest.fixture()defentity():returnEntity(1)@pytest.fixture()deftwo():return2@pytest.fixture()defthree():return3@pytest.fixture()defentity_format():def_entity_format(entity:Entity):return{"value":entity.value}return_entity_format@pytest.mark.parametrize("message",[lfc("There is two lazy fixture args,{}and{}! And one kwarg{field}! And also simple value{simple}".format,lf("entity"),lf("two"),field=lf("three"),simple="value",),],)deftest_lazy_fixture_callable_with_func(message):assertmessage=="There is two lazy fixture args, 1 and 2! And one kwarg 3! And also simple value value"@pytest.mark.parametrize("formatted",[lfc("entity_format",lf("entity"))])deftest_lazy_fixture_callable_with_lf(formatted,entity):assertformatted=={"value":entity.value}@pytest.mark.parametrize("result",[lfc("entity.sum",lf("two"))])deftest_lazy_fixture_callable_with_attr_lf(result):assertresult==3ContributingContributions are very welcome. Tests can be run withpytest.LicenseDistributed under the terms of theMITlicense,pytest-lazy-fixturesis free and open source softwareIssuesIf you encounter any problems, please file an issue along with a detailed description.
Package: pytest-level
pytest-levelMark test cases with alevel, then de-select tests with a given level or higher.When giving a teaching/practice assignment with pre-written tests, either all
tests can be given at once (leaving students overwhelmed and unsure which
failures should be fixed next), or piece-wise (in individual files -- which
becomes a mess for larger projects).With this plugin, tests for a teaching/practice assignment can be given in
a single file. Students are then told to run with--level 1, fix the few red
tests, then go to--level 2, etc.
Unlike with keywords, all the lower-level tests will still be run:--level 2will run bothlevel(1)andlevel(2)tests.InstallationIn a Python environment (e.g.venv), do:python -m pip install pytest-levelUsageMark tests with a numericlevelmarker:@pytest.mark.level(1)
def test_basic_math():
    assert 1 + 1 == 2

@pytest.mark.level(2)
def test_intermediate_math():
    assert 10 / 2 == 5

@pytest.mark.level(3)
def test_complicated_math():
    assert 10 ** 3 == 1000Then, run pytest with--level:python -m pytest --level 2This will deselect tests of a higher level.Without--level, all tests are run.LicenceThe code is available under a MIT license. May it serve you well.
Package: pytest-libiio
A pytest plugin to manage interfacing with libiio contextspytest-libiio is pytest plugin to manage interfacing with libiio contexts. This plugin is handy for leveraging the (new) zeroconf features of libiio to find, filter, and map libiio contexts to tests. It was created forpyadi-iiotesting but is used in other applications that need an organized way to handle libiio contexts without hardcoding URIs or lots of boilerplate code.Requirementslibiio and pylibiiopytestpyyamlFor development the following are also needed:toxpytest-mockpre-commitisortflake8codespellblackInstallationYou can install “pytest-libiio” viapipfromPyPI:$ pip install pytest-libiioUsageThis plugin is used to make the access of libiio contexts easier and to provide a unified API through fixtures.Accessing contextsGet list of context descriptions of all found containedimportpytestimportiiodeftest_libiio_device(context_desc):hardware=["pluto","adrv9361","fmcomms2"]forctx_descincontext_desc:ifctx_desc["hw"]inhardware:ctx=iio.Context(ctx_desc["uri"])ifnotctx:pytest.skip("No required hardware found")Require certain hardware through marksimportpytestimportiio@pytest.mark.iio_hardware("adrv9361")deftest_libiio_device(context_desc):forctx_descincontext_desc:ctx=iio.Context(ctx_desc["uri"])...Future ideasMock testing is common with libiio’s python library since hardware is needed otherwise. In future releases we hope to extend features in pytest-mock through this plugin to make mocking libiio more streamlined.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 theBSD-3license, “pytest-libiio” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-libnotify
pytest libnotifyNotifications for pytest that update while the tests are running & show failing
tests before the test session finished.Installationpipinstallpytest-libnotifyLicense:MITCopyright 2018 Martin VielsmaierPermission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Package: pytest-ligo
Py.test plugin which adds a ligo fixture to encapsulate boilerplate business
logic. Refer totest_pytest_ligo.pyfor example usage.Install with pip, ie:pip install pytest-ligoYou also need ligo, which you can install in ~/.local/bin with:curl https://gitlab.com/jpic/pytest-ligo/raw/master/install.sh | bash -eux -Note: the above works on arch linux and ubuntu-18.04 without extra
configuration. For debian, export distro=debian-10 or distro=debian-9 prior to
the above command.
Package: pytest-lineno
pytest-linenoA pytest plugin to show the line numbers of test functions.Installationpipinstallpytest-lineoUsagepytest--show-lineno--verboseThe output should look like:tests/test_file.py:0::test_funcPASSED[50%]tests/test_file.py:5::TestClass::test_methodPASSED[100%]# ^^^# By clicking `tests/test_file.py:5`,# you can jump to `TestClass.test_method`