Saravanan666/pypi-org huggingface dataset:
Package: pytest-split-tests
pytest-split-tests allows you to split your test runs into groups of a specific
size to make it easier to split up your test runs.Usage# Install pytest-split-tests
pip install pytest-split-tests

# Split the tests into 10 groups and run the second group
py.test --test-group-count 10 --test-group=2

# Assign tests pseudo-randomly into 10 groups, and run the second group
py.test --test-group-count 10 --test-group=2 --test-group-random-seed=12345Why would I use this?Sometimes you may have some long running test jobs that take a
while to complete. This can be a major headache when trying to
run tests quickly. pytest-split-tests allows you to easily say
“split my tests into groups of 10 tests and run the second group”.
This is primarily useful in the context of CI builds.
Package: pytest-sqitch
sqitch for pytestThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-sqitch” viapipfromPyPI:$ pip install pytest-sqitchUsageTODOContributingContributions 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-sqitch” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-sqlalchemy-mock
pytest-sqlalchemy-mock  👋This plugin provides pytest fixtures to create an in-memory DB instance on tests and dump your raw test data.Installationpip install pytest-sqlalchemy-mockUsageLet's assume you have a SQLAlchemy declarative base and some models with it.models.pyfromsqlalchemyimportColumn,Integer,Stringfromsqlalchemy.ormimportdeclarative_baseBase=declarative_base()classUser(Base):__tablename__="user"id=Column(Integer,primary_key=True)name=Column(String)Firstly SQLAlchemy base class which is used for declare models should be passed withsqlalchemy_declarative_basefixture inconftest.pyconftest.py@pytest.fixture(scope="function")defsqlalchemy_declarative_base():returnBaseThen in test functions you can usemocked_sessionfixture to make query in mocked DB.test_user_table.pydeftest_mocked_session_user_table(mocked_session):user_data=mocked_session.execute("SELECT * from user;").all()assertuser_data==[]Also, you can dump your mock data to DB before start testing viasqlalchemy_mock_configfixture like following.conftest.py@pytest.fixture(scope="function")defsqlalchemy_mock_config():return[("user",[{"id":1,"name":"Kevin"},{"id":2,"name":"Dwight"}])]test_user_table.pydeftest_mocked_session_user_class(mocked_session):user=mocked_session.query(User).filter_by(id=2).first()assertuser.name=="Dwight"Upcoming FeaturesMock with decorator for specific DB states for specific cases.Support to load data from.jsonand.csvAsync SQLAlchemy support
Package: pytest-sqlalchemy-session
pytest-sqlalchemy-sessionInstallationYou can install "pytest-sqlalchemy-session" viapipfromPyPIpipinstallpytest-sqlalchemy-sessionFeaturesTODOUsageTODOContributingContributions are very welcome. Tests can be run withnox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theMITlicense, "pytest-sqlalchemy-session" is free and open source software
Package: pytest-sql-bigquery
Pytest plugin for Bigquery SQLpytest-sql-bigquery is pytest-plugin which provides a sql-unitest-framework for BigQuery.
This plugin adopts an end-to-end approch that runnning SQL test on SQL engines.Yet anthoer approch to tst SQL codeSee following SQL codes:withdatasetas(select1unionallselect2),__check_sampleas(select'test'aslabel,count(1)asactual,2asexpectedfromdataset)select*fromdatasetThis code is minimal example including test case.__check_sampleis a test case which makes sure thedatasetview has just 2 record.Our idea is very simple: "Verify SQL code by SQL-self."This plugin generate SQL test codes from SQL and executed them on SQL-engine such as BigQuery.The advantages of this approch areSQL codes owns specification itselfProvide portability of logic and its test codes.Free to hard-mocking database systemGet StartedRequirementsPython >= 3.7sqlparsegoogle-cloud-bigquery (For BigQuery integration)BigQuery (Google Cloud Project)Installpip install pytest-bigquery-sqlThen, set upconfidist.pyfor pytest settings.importpytestfrompytest_sql_bigquery.integrations.pytestimportSQLReaderForCheckingclassChainPytestFile(pytest.File):def__init__(self,path,parent,chains,**kwargs):super().__init__(path,parent,**kwargs)self.chains=chainsdefcollect(self):forinterpreterinself.chains:yield frominterpreter.collect()defpytest_collect_file(parent,path):ifpath.ext==".sql":returnChainPytestFile(path,parent,[SQLReaderForChecking(path,parent),])Run test forexamples/sqldirectorypytest run -vv examples/sql
Package: pytest-sqlfluff
Apytestplugin to usesqlfluffto enable format checking of sql files.FeaturesTests any sql files found in project.Leverages existingsqlfluffconfigurations.Skips unchanged sql files.RequirementsPython 3.7+sqlfluff1.0.0+InstallationYou can installpytest-sqlfluffviapipfromPyPI:$ pip install pytest-sqlfluffUsageOut of the box, you can runpytest-sqlfluffas argument topytest:$ pytest --sqlfluff
====================================== test session starts ======================================
platform darwin -- Python 3.9.6, pytest-7.2.0, pluggy-1.0.0
rootdir: /code/github.com/prsutherland/pytest-sqlfluff
plugins: sqlfluff-0.1.0
collected 1 item

tests/file.sql .                                                                          [100%]

======================================= 1 passed in 0.45s =======================================To configure your sqlfluff linting, use the standardsqlfluff configurationmechanisms. At the very
least, you’ll likely need to set the dialect.:[sqlfluff]
dialect = postgres
...ContributingContributions are very welcome. Tests can be run withpytest, please ensure
the coverage at least stays the same before you submit a pull request.To get started:$ git clone https://github.com/prsutherland/pytest-sqlfluff.git
$ cd pytest-sqlfluff
$ poetry installRun tests:$ poetry run pytestLicenseDistributed under the terms of theMITlicense, “pytest-sqlfluff” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-squadcast
pytest-squadcastPytest report plugin forSquadcastAllow to send incident on Squadcast product.installationpip install pytest-squadcastAdd option to send messagepytest --squadcastCreate payload via hookdef pytest_squadcast_create_payload(session: Session) -> dict:
    reporter = session.config.pluginmanager.get_plugin('terminalreporter')
    return {"data": {
                        "message": "This will be the incident message",
                        "description": "This will be the incident description",
                        "tags": {
                            "passed": str(reporter.stats.get('passed', [])),
                            "tagname2": "Tag value#2",
                        },
                        "status": "trigger",
                    },
            "service": "0d2a4409625e05adbc1d81b3540ag89826bfa7cc",
            }DevChange versioneditpytest_squadcast/__init__.pycommitgit commit -m "v0.1.0"taggit tag v0.1.0Build packagepython -m build
twine upload dist/*
Package: pytest-srcpaths
pytest-srcpathsAdd paths tosys.path.A pytest plugin to help pytest find the code you want to test.InstallationInstall with pip:pip install pytest-srcpathsUsageAdd a line in your pytest.ini file with a key ofsrcpaths.
It should contain a space-separated list of paths.[pytest]
srcpaths = src libPaths are relative to the directory that pytest.ini is in.You can include the top level directory with a dot.[pytest]
srcpaths = .Alternatively, usepythonpathThe optionpythonpathalso works the same.[pytest]
pythonpath = src libpytest 7 (not released yet) is planned to include thepythonpathoption.For pytest 6.2.x, this plugin will work.Changelog1.2.1 - Addpythonpathas an alternative tosrcpathoption for pytest versions < 7.0.0this is to allow this project to act as a temporary workaround until pytest 7 is releasedSimilar projectThis plugin was inspired bypytest-pythonpathwhose implementation and scope are a bit different.
Package: pytest-static
pytest-staticOverviewpytest-static is a pytest plugin that allows you to parametrize your tests using type annotations.What this looks like in practice is that you can write a test like this:importpytestfromtypingimportTuple@pytest.mark.parametrize_types("a",[Tuple[bool,bool]])deftest_a(a:bool)->None:assertisinstance(a,bool)Which would be equivalent to the following testimportpytest@pytest.mark.parametrize("a",[(True,True),(True,False),(False,True),(False,False)])deftest_a(a:int)->None:assertisinstance(a,int)For types such as int, str, etc that have an unlimited amount of values, there are premade sets meant to cover common edge cases that are used by defaultHowever, you can also override these defaults if you wish by passing an instance of Config with some custom handlers set.FeaturesRequirementsTODOInstallationYou can installpytest-staticviapipfromPyPI:$pipinstallpytest-staticUsagePlease see theCommand-line Referencefor details.ContributingContributions are very welcome.
To learn more, see theContributor Guide.LicenseDistributed under the terms of theMIT license,pytest-staticis free and open source software.IssuesIf you encounter any problems,
pleasefile an issuealong with a detailed description.CreditsThis project was generated from@cjolowicz'sHypermodern Python Cookiecuttertemplate.
Package: pytest-statsd
pytest-statsdInstallationInstall through pip:pipinstallpytest-statsdInstall from source:cd/path/to/source/pytest-statsd
pythonsetup.pyinstallExampleTo simply run using default the configuration, use:pytest--stats-dtests/If there is a need to configure where to sent results to other than localhost:8125, use:pytest--stats-d--stats-hosthttp://myserver.com--stats-port3000tests/You can also prefix your results if you plan on having multiple projects sending results to the same server:pytest--stats-d--stats-prefixmyprojecttest/
Package: pytest-stepwise
Introductionpytest-stepwise is a plugin forpytestthat run
all tests until a test fails, and then continue next test run from where
the last run failed. You may think of it as a combination of the-xoption, which exits the test run after a failing test, and the--lfoption from pytest-cache, which only runs failing tests.pytest-stepwise depends on pytest-cache, which will be installed as a
dependency.How to use it?Install the plugin -pip installpytest-stepwise.Runpy.test--stepwise(you can also use the alias--sw).Watch the test fail and fix it.Runpy.test--stepwiseagain. The test suite will continue to run
right from where it was.Use the--skipoption to ignore one failing test and stop the
test execution on the second failing test instead. This is useful if you
get stuck on a failing test and just want to ignore it until later.When is this useful?pytest-stepwise was written for use when a large part of the test suite
is failing. In this case, pytest-stepwise allows you to focus on fixing
one test at the time instead of being overwhelmed by all failing
tests. It should however be noted that all tests need to be re-run after
to make sure that any changes made when fixing one test has not broken
some other test.Please submit an issue if you have any suggestions regarding use cases
of pytest-stepwise.Compatibilitypytest-stepwise is compatible with pytest 2.2 -> 2.8.
For pytest 2.7 and earlier,pytest-cacheis required as a dependency.Changelog0.1 - Initial version.0.2 - Clear cache after test run when the plugin is not active.
Added--skipoption.0.3 - Fixed issue when failing tests are removed.
Fixed compatibility with--pdboption.
Stop on errors as well as on test failures.0.4 - Refactoring, pytest 2.8 compatiblity. Stop test execution on
collection errors.
Package: pytest-stf
pytest plugin for OpenSTFPlugin for simplifyOpenSTFusage with pytest
framework by providing simple fixture that do all primitive tasks for appium based tests.Target is to easily scale up tests in CI environment where external stf service is used to
provide android phones.Plugin based onstf-appium-python-clientpytest argumentsopenstf:
  --stf_host=STF_HOST   Openstf host
  --stf_token=STF_TOKEN
                        Openstf access token
  --phone_requirements=PHONE_REQUIREMENTS
                        Phone requirements
  --stf_allocation_timeout=STF_ALLOCATION_TIMEOUT
                        Maximum time in seconds after which STF releases allocated devices
  --appium_server=APPIUM_SERVER
                        Appium server API URL
  --appium_capabilities=APPIUM_CAPABILITIES
                        Appium capabilities
  --appium_logs=APPIUM_LOGS
                        Appium server log file pathFixturesallocated_phoneSession scopedFind and allocate a phone based on--phone_requirementscli argument from STF or using pytest-lockableNOTE:only one phone is handled by this fixture.phone_with_adbSession scopedDepends onallocated_phoneCreate ADB tunnel to phone if using STFNOTE:Android SDK(commandline tools, platform tools and build tools) need to be installed separately!appium_serverSession scopedDepends onphone_with_adbStart Appium server or alternatively use remote one passed via--appium_servercli argument orappium_serverlockable resource propertyNOTE:appiumneed to be installed separately! (npm i appium) .appium_clientSession scopedDepends onappium_serverStart Appium webdriver clientcapabilitiesSession scopedReturns arguments passed to Appium webdriverTests can override this fixture in order to pass custom argumentsappium_argsSession scopedReturns arguments passed to Appium serverTests can override this fixture in order to pass custom argumentsUsage examplesample.py:fromappium.webdriver.webdriverimportWebDriverdeftest_create(appium_client):client,appium,adb,phone=appium_client# device is dictionary of device metadata# adb: AdbServer instance, that is already connected# appium: AppiumServer instance that provide server address for appium clientprint(phone)print(f'wd_hub:{appium.get_api_path()}')client:WebDriverclient,*_=appium_clientURL='https://google.com'client.get(URL)url=client.current_urlasserturl==URL,'Wrong URL'Execution:> pytest sample/test_samples.py --stf_host localhost --stf_token $TOKEN --phone_requirements platform=AndroidSee more examples fromsample/test_samples.py.Custom capabilities:> pytest --appium_capabilities cab=val1&cab=val2Usage with local devicesTesting with a local device you can omit--stf_hostand--stf_tokencli arguments and use lockable resources file (defaults toresources.json).resources.jsonexample:[
  {
    "id": "1",
    "type": "Phone",
    "platform": "Android",
    "online": true,
    "hostname": <HOSTNAME>,
    "version": "12",
    "appium_server": "http://localhost:4723"
  }
]Execution:> pytest sample/test_samples.py --phone_requirements platform=AndroidNOTE:Appium server need to be run separately! (appium -a 127.0.0.1)
Package: pytest-stoq
A plugin to pytest stoq.This plugin automatically set up the stoq test environment. It also provide a range of
fixtures to ease the testing of stoq-related projects.InstallationYou can install “pytest-stoq” viapipfromPyPI:$ pip install pytest-stoqCommand-line options--plugin-cls: the plugin class path to be installed. Useful for testing stoq plugin projects.--quick: setup stoq using the quick strategy.--skip-env-setup: pytest-stoq won’t setup the database, install plugins etc. (in case you already have the test env ready).--stoq-plugins: a comma-separated list of stoq plugin names to be installed. Useful for testing stoq applications that uses plugins (such as stoq desktop and stoq server).Config file optionsPLUGIN_CLASS: same as--plugin-clsSTOQ_PLUGINS: same as--stoq-pluginsFixturesThe plugin provides the following fixtures:store: an instance of storm’s (ORM) store used to access the database. It suffers rollback after each test case and cannot be committed, closed or rollbacked manuallyexample_creator: instance creates (inserts) database objects with example/test datasysparam: a sysparam instance that clear its cache automatically after each usecurrent_stationcurrent_usercurrent_branchcurrent_tillmock_new_store: replacestoqlib.api.new_store()with thestorefixtureLocal Development(optional) Setup your virtualenv using python 3.5+Install test requirements:$ pip install -Ur requirements-test.txtSetup pre-commit:$ pre-commit installRun tests using pytest:$ make testLicenseDistributed under the terms of theGNU GPL v3.0license, “pytest-stoq” is free and open source software
Package: pytest-store
pytest-storeRerun whole testsuites for a certain time or amountStill under development.Arguments--store-type <pl|pd|list-dict|none>Set store type (default: installed extra)--store-save <path>Save file to path, format depends on the ending unless specified.--store-save-format <format>Save format, depends on store type.--store-save-forceOverwrite existing fileNOTE:All arguments can also be set as environment variables, e.g.RERUN_TIME="1 hour", orinioption, e.g.rerun_time="10 min".Examples# save results as polars and export to excelpytest--store-typepl--store-saveresults.xlsexamplesInstallationYou can installpytest-storeviapipfromPyPIor thisrepo:pipinstallpytest-store[<extra>]# extras = "all", "pandas", "polars", "database", "excel", "parquet"pipinstallpytest-store[polars,excel,database]pipinstallgit+git@github.com:TBxy/pytest-store.git@main# latest versionpipinstallpytest-store--all-extras# developmentTodosSQL backend, which saves as streamWrite testsGithub ActionsContributingContributions are very welcome.
Tests are not ready at the moment, use the example scripts.LicenseDistributed under the terms of theMITlicense,pytest-storeis free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Thispytestplugin was generated withCookiecutteralong with@hackebrot'scookiecutter-pytest-plugintemplate.
Package: pytest-stress
A plugin that allows you to loop tests for a user-defined amount of time.RequirementsOnly tested withPytestversion 5.2.2.InstallationYou can install “pytest-stress” viapipfromPyPI(highly recommend installing in aPipenv):$ pip3 install pytest-stressUsageLoop tests for 30 seconds:$ pytest --seconds 30Loop tests for 45 minutes:$ pytest --minutes 45Loop tests for 8 hours:$ pytest --hours 8Loop tests for 1 hour 8 minutes and 9 seconds:$ pytest --hours 1 --minutes 8 --seconds 9Need to wait some time after each test loop? Don’t say I don’t love you:$ pytest --delay 5 --hours 4 --minutes 30You can also add these values to config files:[pytest]
addopts = --hours 1 --minutes 30Note: These loop times include setup and teardown operations as well. So if you have a test setup that takes 5
seconds, your actual tests will run for 5 seconds less than your desired time.ContributingContributions are very welcome! Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theMITlicense, “pytest-stress” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Thispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.
Package: pytest-structlog
pytest-structlogStructured logging assertions.pytest+structlog=pytest-structlog.Installation:$pipinstallpytest-structlogUsage:The fixture name islog. It has two attributes of interest:log.eventsis a list of events from captured log calls, andlog.hasis a helper function for asserting a single event was logged within the expected context.Suppose you have some library module,your_lib, which is usingstructlog:# your_lib.pyfromstructlogimportget_loggerlogger=get_logger()defspline_reticulator():logger.info("reticulating splines")foriinrange(3):logger.debug("processing",spline=i)logger.info("reticulated splines",n_splines=3)Then your test suite might use assertions such as shown below:# test_your_lib.pyfromyour_libimportspline_reticulatorimportpytest_structlogdeftest_spline_reticulator(log:pytest_structlog.StructuredLogCapture):assertlen(log.events)==0spline_reticulator()assertlen(log.events)==5# can assert on the event onlyassertlog.has("reticulating splines")# can assert with subcontextassertlog.has("reticulated splines")assertlog.has("reticulated splines",n_splines=3)assertlog.has("reticulated splines",n_splines=3,level="info")# but not incorrect contextassertnotlog.has("reticulated splines",n_splines=42)assertnotlog.has("reticulated splines",key="bogus")# can assert with the event dicts directlyassertlog.events==[{"event":"reticulating splines","level":"info"},{"event":"processing","level":"debug","spline":0},{"event":"processing","level":"debug","spline":1},{"event":"processing","level":"debug","spline":2},{"event":"reticulated splines","level":"info","n_splines":3},]# can use friendly factory methods for the events to assert onassertlog.events==[log.info("reticulating splines"),log.debug("processing",spline=0),log.debug("processing",spline=1),log.debug("processing",spline=2),log.info("reticulated splines",n_splines=3),]# can use membership to check for a single event's dataassert{"event":"reticulating splines","level":"info"}inlog.events# can use >= to specify only the events you're interested inassertlog.events>=[{"event":"processing","level":"debug","spline":0},{"event":"processing","level":"debug","spline":2},]# or put the comparison the other way around if you preferassert[{"event":"processing","level":"debug","spline":0},{"event":"processing","level":"debug","spline":2},]<=log.events# note: comparisons are order sensitive!assertnot[{"event":"processing","level":"debug","spline":2},{"event":"processing","level":"debug","spline":0},]<=log.events
Package: pytest-stub
https://github.com/idlesign/pytest-stubDescriptionStub packages, modules and attributes.This pytest plugin allows you to replace dependencies with stubs.It can be useful if you want to test some code using a dependency without actually having this dependency,
for example if you’re testing your library, which uses some parts of another library.RequirementsPython 3.6+pytest >= 2.9.0How to useYou can stub dependencies either with your own custom objects or you may instructpytest-stubto generate functions or classes for you. Usestubfixture in your test functions, like this:deftest_django_related(stub):stub.apply({# Replace `call_command` with a generated function.'django.core.management.call_command':'[func]',# Replace `BaseCommand` with a generated class.'django.core.management.base.BaseCommand':'[cls]',# Replace `dummy` with generated MagicMock.'django.dummy':'[mock]',# Replace entire `cv2` module.'cv2':'[mock]',# Sometimes we need just a persistent (always the same) magic mock.'numpy':'[mock_persist]',# Stub multiple attributes in the same module with custom objects.'django.conf':{'settings':object(),'some':True,},})If we want to replace some dependency with a stub not in a fixture but globally, we can usestub_global()function
in rootconftest.py(this code will apply patch before tests, so tests will be safe to import code using dependencies).frompytest_stub.toolboximportstub_globalstub_global({'cv2':'[mock_persist]',})
Package: pytest-stubprocess
Mock out subprocesses to use stub implementations in PythonThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsTODOInstallationYou can install “pytest-stubprocess” viapipfromPyPI:$ pip install pytest-stubprocessUsageTODOContributingContributions 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-stubprocess” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.