Saravanan666/pypi-org huggingface dataset:
Package: pytest-pointers
Pytest Plugin to Show Unit CoverageCodecoverage tools likecoverage.pyshow you the
instrumented code coverage of your tests, however it won't tell you if you've
written specific unit tests for each of your code'sunits(here unit meaning
function).This package implements a mechanism for measuring and reporting unit coverage.
Instead of instrumenting your code you will need to mark tests with apointerto the unit that it is covering.For example if you have in your code this modulemypackage/widget.py:deffoo(in):returnin*3then in your test suite you would write a unit test for this function and mark it as relating to that unit, e.g. intests/test_widget.py:frommypackage.widgetimportfoo@pytest.mark.pointer(foo)deftest_foo():assertfoo(3)==9This package works by collecting all of the pointed-to units during test
execution and persists these to the pytest cache (typically somewhere under.pytest_cache). Then in subsequent runs you need only report the results.InvocationThis package adds a couple new options to thepytestCLI:--pointers-collect=STR(defaultsrc)This explicitly indicates to collect unit coverage results. If not specified,
but--pointers-reportis given results will be collected using the default.--pointers-report(defaultFalse)When this flag is given a textual report will be given at the end of the test
run. Note that even if this is not given the coverage checks will still be run.--pointers-func-min-pass=INT(default2)This flag controls the number of unit test pointer marks are needed to get a
"passing" unit. In the report units with 0 pointers are shown as red, passing
numbers are green, and anything in between is blue.--pointers-fail-under=FLOAT(default0.0)This flag controls the percentage of passing units are needed for the entire
coverage check to pass. The percentage is always displayed even without--pointers-report. If this test is failed then the test process exits with
code 1, which is useful for things like CI.ExampleHere is an example with source code under thesrcfolder, requiring 1 pointer
test per collected unit in the code, for all functions.pytest --pointers-report --pointers-collect=src --pointers-func-min-pass=1 --pointers-fail-under=100 testsInstallationpipinstallpytest_pointers
Package: pytest-polarion-cfme
NOTE: pytest-polarion-cfme is no longer using pylarion as pylarion is being
deprecated. As a consequence command line options changed too.pytest-polarion-cfme is a pytest plugin for collecting test cases and recording
test results to database.From set of test cases specified on command line the plugin selects such test
cases that are present in the database and have no reportable result yet.After executing a test case the plugin records its result in the database. By
default results for passed and blocked (test cases with blocker or ‘skipif’)
test cases are recorded.It is tailored for the CFME QE team.UsageGenerate sqlite3 file out of the CSV file exported from Polarion®. Use thecsv2sqlite.pyfromdump2polarionfor this.From test cases available to pytest (you can limit these using standard pytest
features like-kor specifying file/directory path) select and run those
that are present in the database and have no reportable result. Record results
for test cases that passed or that are blocked:$ py.test --db <db_file.sqlite3>To exclude tests that were already executed but haven’t passed, add--skip-executedcommand line option (i.e. failing/skipped tests are not
re-run and it saves time):$ py.test --db <db_file.sqlite3> --skip-executedSubmit results to Polarion® xunit importer usingpolarion_dumper.pyfromdump2polarion.InstallFor CFME QE specific instructions seehttps://mojo.redhat.com/docs/DOC-1098563(accessible only from internal network).Install this plugin:$ pip install pytest-polarion-cfme
Package: pytest-ponyorm
PonyORM in PytestPlugin for usePony ORMinPytest.ThisPytestplugin was generated withCookiecutteralong with@hackebrot’sCookiecutter-pytest-plugintemplate.FeaturesAccess Database instance (db) viaponydbfixtureMark tests to auto allow use ofpony.orm.db_sessionDatabase is by default cleared after each testDatabase reset can be cancelled for test/class/moduleRequirementsTested fromPony ORM>= ‘0.7.3’ and python : 3.5, 3.6InstallationYou can install “pytest-ponyorm” viapipfromPyPI:$ pip install pytest-ponyorm
or
$ pipenv install -d pytest-ponyormUsageWarningBy default, database is cleared after each test. You must never use it in a production environment. This plugin doesn’t change the database config.It’s you’job to create the testing environment and change database params.First, configure PONY_DB in pytest.ini. PonyORM main Database instance  module location must be specified in pytest.ini to make it work : for example if db is in /path/models/main.py, you must configure like this :[pytest]PONY_DB=path.models.mainThen just apply the pony marker :# models.pydb=Database()# test.py@pytest.mark.ponydefmy_test(ponydb):new_mod=ponydb.Mymodel(name="me",...)You can mark a class or function with @pytest.mark.pony or the whole module with pytestmark = pytest.mark.ponyThe markerponytakes one argument :reset_db, default is True. In this case the marked test doesn’t reset the database at ending.# test.pypytestmark=pytest.mark.pony# marks all tests of the moduledeftest1:passdeftest2:pass@pytest.mark.pony(reset_db=False)deftest3:pass# test3 will use database in the state that test2 left it.About Reseting Database:Test database tables are dropped/recreate before the test SESSION.Initialy this plugin did drop/recreate table  for each test. Due to perfomance reason, this has changed. Now tables are cleared but not dropped.Sql sequences like  “auto PrimaryKey”  will also be reset but actually, it’s only supported for PostgreSQL and Sqlite. For other databases, Primarykey might not start at 1 for each test. This has to be considered when writing tests.About Fixtures :Fixtures should not use db_session decorator or context manager. Each test is automaticaly run inside a db_session  and each operation inside fixtures will be commited at test start.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 theGNU GPL v3.0license, “pytest-ponyorm” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Changelog0.3.1 :sql sequence reset for postgre and sqlitetesting py35/36 and pg/sqlite0.3.0 :made faster with just deleting database entries after each testno drop/recreatedb_session splitted into 2 hooks, not anymore in a fixture0.2.9 :add fixture autocommit before run test0.2.0 :add marker0.1.5 :add db_session for each test0.1.0 :auto clear database
Package: pytest-poo
pytest-poo is a plugin forpytestthat points out your
crappy tests with piles of poo.Really? Why?I showed the –poo option at EuroPython 2013. A number of people thought I
should release it, so here it is.ScreenshotsThis is what the output usually looks like:… when passing –poo, this is what is outputted instead:RequirementsA recent version of pytest is required (>= 2.3.4).Quick startpip installpytest-pooMark tests with thepytest.mark.poomarker.Run tests with the –poo option to enable pile of poo output.DocumentationMarking testsAdd thepytest.mark.poomarker to the tests that you consider crappy. The
markers are standard py.test markers and can be used like this on a test
function:importpytest@pytest.mark.poodeftest_something():assert0or for classes:importpytestclassMyTests(object):pytestmark=[pytest.mark.poo]… or for entire modules:importpytestpytestmark=pytest.mark.poodeftest_a():assert0deftest_b():assert0Showing crappy tests during test runJust run py.test with the--poooption to enable the output. To always
enable, add--pooto addopts in pytest.ini:[pytest]addopts=--poo
Package: pytest-poo-fail
pytest-poo is a plugin for `pytest <http://pytest.org/>`_ that points out yourcrappy tests with piles of poo.Requirements============A recent version of pytest is required (>= 2.3.4).Showing crappy (failed)  tests during test run------------------------------------Just run py.test with the ``--poo`` option to enable the output. To alwaysenable, add ``--poo`` to addopts in pytest.ini::[pytest]addopts = --poo
Package: pytest-pook
pytest-pookA pytest plugin forpook.Installationpip install pytest-pookPytest automatically finds and configures the plugin.The project is only tested on the latest versions of pook and pytest.Issue trackerpytest-pookusesSourcehut for issue tracking. You can also submit issues and participate in their discussions via email if you don't have a Sourcehut account:~sara/pytest-pook@todo.sr.ht.Read documentation for Sourcehut's issue tracker here.Usage@pytest.mark.pookTests that rely on pook can be marked with@pytest.mark.pook. The mark wraps the test inpook.use()in a way compatible with pytest, that does not interfere with other marks. It also asserts that any declared pook mocks were actually matched. This prevents the easy mistake of declareing a mock intenteded to be matched, but that never matches. Normally this requires manually assertingpook.isdone()at the end of a test, but this is too easy to forget and is tedious anyhow.Within the body of the test, use the global pook import to interact with pook for things like creating new mocks.Use the mark's default behaviour as follows:importpytestimportrequestsimportpook@pytest.mark.pookdeftest_network_call():pook.get("https://example.com").reply(200).body("Hello from pook")res=requests.get("https://example.com")assertres.text=="Hello from pook"Delay pook activationIf your test requires real network calls to happen before pook is enabled, passstart_active=Falseto the mark to delay pook activation untilpook.onis called:importpytestimportrequestsimportpook@pytest.mark.pook(start_active=False)deftest_network_call():fixture=requests.get("localhost:8080/my-fixture").json()(pook.post("https://example.com").json(fixture).reply(200).body("Hello from pook"))pook.on()res=requests.get("https://example.com",data=fixture)assertres.text=="Hello from pook"With this approach, you still get the benefits of automatic cleanup and checks, but can still make outbound network calls before pook starts capturing them later in your test.Dangling or unused pending mocksBy default the plugin raises an exception if it detects if pending mocks exist after the test is finished. This helps catch the easy-to-miss edge case where a pook was intended to match a request but didn't match any. This is commonly caused either by the tested code not using a compatible HTTP library or by misconfigured mocks.To disable this check, passallow_pending_mocks=Trueto the mark. In this case, it is recommended to manually confirm the mocks are in the expected state at the end of the test.ContributingThis project useshatchto manage testing and development environments.LintingConfigure linting before you start development withhatch run installprecommit.Run the linter at any time withhatch run lint.TestsTests run with pytest in the hatchtestenvironment. Tests are configured to run with all supported Python versions. Run tests for all versions:hatch run test:testTo run tests only for a specific environment:hatch run test.py3.12:testChangelog1.0.0Initial stable release of the plugin.
Package: pytest-portion
Select a portion of the collected tests, so you can run diferents parts of your test suite
in differents instances to balance the number of test run on each one.Use caseSuppose you have a big, slow test suite, but you can trigger several CI workers
to run different portions of it, in a sake lazy/simple way to parallelize it.A basic, obvious way to do that is to explictily
collect from different directories/modulesworker1:pytest tests/a(100 tests, ~4 minutes to finish)worker2:pytest tests/b(20 tests, ~1 minute to finish)worker3:pytest tests/c tests/d(30 tests, ~1 minute to finish)The problem is that directorytests/amay have a lot more tests thattests/cplustest/d,
soworker1takes a lot more to finish.Withpytest-portionyou can still split the tests in different instances, but letting
the extension makes the selection in a more balanced way.worker1:pytest--portion1/3 tests(first 50 tests, ~2 minutes)worker2:pytest--portion2/3 tests(next 50 tests, ~2 minutes)worker3:pytest--portion3/3 tests(last 50 tests, ~2 minutes)In this case, the tests of all the directories are collected, but only a third (a different one!) of them will
be actually executed on each worker.Note this balance isby number of tests, so if there is very slow tests in a particular portion,
the duration may not be expected.For a fine tuning, you could pass the portion in a more explicit way:worker1:pytest--portion0:0.5 tests(first half, 1st to 75th test)worker2:pytest--portion0.5:0.8 tests(next 30%, from 76th to 125º)worker3:pytest--portion0.8:1 tests(last 20%)InstallationYou can install “pytest-portion” viapipfromPyPI:$ pip install pytest-portionUsagePass--portion<i/n>where:nis the number of portionsiis the i-th portion to select (1 <= i <= n)NoteIf the number of tests collected is not divisible byn, the last portion will contain the rest.
For instance, if you havetest_1,test_2andtest_3,–portion 1/2will run the first one,
and–portion 2/2the last 2.Alternatively--portionstart:endwhere:startandendare the coefficient (between 0 and 1) that represent the segment of the collected tests
to select.ContributingContributions are very welcome. Please ensure the coverage at least stays
the same before you submit a pull request.LicenseDistributed under the terms of theBSD-3license, “pytest-portion” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.AcknowledgementsThanks toShipHerofor give me some time to develop this.I usedcookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate for the boilerplate code of this package. Thanks!
Package: pytest-power
pytest-powerAdds a number of shorthands for fixtures and other helpers for easier testing:patch.objectpatch.initpatch.manypatch.everythingYou can instal pytest-power with pip:pipinstallpytest-powerUsagepatch.objectA shorthand for pytest-mock'smocker.patch.objectfrommyappimportAppdeftest_app_run(patch):patch.object(App,'run')App.run()assertApp.run.call_count==1You can pass keywords arguments as usual:frommyappimportAppdeftest_app_run(patch):patch.object(App,'run',return_value='running')assertApp.run()=='running'patch.initMakes patching__init__a bit simpler:frommyappimportAppdeftest_app_init(patch):patch.init(App)app=App()assertisinstance(app,App)Instances patched in this way do not have properties that are set in__init__,
so they have to be set again by hand.Keyword arguments are passed to underlyingpatch.object, and autospec is
enabled by default.Multiple classes can be passed too:patch.init(App,Cli)patch.manyA shorthand to patch many properties of the same object:frommyappimportAppdeftest_app_run_called_by_run(patch):patch.many(App,['run','called_by_run'])App.run()assertApp.called_by_run.call_count==1Keyword arguments are again passed to underlyingpatch.object, and autospec
is enabled by default.patch.everythingA shorthand to patch every non-magic property. Useful when patch.many gets
too long!frommyappimportAppdeftest_app_run_called_by_run(patch):patch.everything(App)App.run()assertApp.called_by_run.call_count==1Supports forcing the exclusion of properties:frommyappimportAppdeftest_app_run(patch,excludes=['run']):patch.everything(App)App.run()assertApp.called_by_run.call_count==1And forcing the inclusion of properties:frommyappimportAppdeftest_app_run(patch,includes=['__private__']):patch.everything(App)App.run()assertApp.__private__.call_count==1
Package: pytest-prefer-nested-dup-tests
by Marximus Maximus (https://www.marximus.com)A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages.By default, when de-duplicating tests, all sub-packages become top level packages. This plugin keeps
the subpackage structure intact.InstallationYou can install viapipfromPyPI:$ pip install pytest-prefer-nested-dup-testsUsageThe plugin is enabled by default, no other action is necessary.ContributingContributions are very welcome. Please seeCONTRIBUTING.rst.LicenseDistributed under the terms of theMITlicense, “pytest-prefer-nested-dup-tests” is free and open source software.License file is available atLICENSEin “plaintext” (ASCII (ASCII-7), Extended ASCII (ASCII-8), Latin-1,
Windows-1252, and UTF-8 compatible format).IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.ChangelogPlease seeCHANGELOG.rst.Like My Work & Want To Support It?Main Website:https://www.marximus.comPatreon (On Going Support):https://www.patreon.com/marximusKo-fi (One Time Tip):https://ko-fi.com/marximusmaximus
Package: pytest-pretty
pytest-prettyOpinionated pytest plugin to make output slightly easier to read and errors easy to find and fix.pytest-pretty's only dependencies arerichand pytest itself.Realtime error summaryOne-line info on which test has failed while tests are running:Table of failuresA rich table of failures with both test line number and error line number:This is extremely useful for navigating to failed tests without having to scroll through the entire test output.Prettier Summary of a Test RunIncluding time taken for the test run:Installationpip install -U pytest-prettyUsage with GitHub ActionsIf you're using pytest-pretty (or indeed, just pytest) with GitHub Actions, it's worth adding the following to the top of your workflow.ymlfile:env:COLUMNS:120This will mean the pytest output is wider and easier to use, more importantly, it'll make the error summary table printed by pytest-pretty much easier to read, seethisdiscussion for more details.pytester_prettyfixtureThepytest_prettyprovidespytester_prettyfixture that work with modified version of output. It is designed to drop in places replacement ofpytesterfixture and uses it internaly.So to use them it is required to setpytest_plugins = "pytester"as mentioned in pytest documentationhttps://docs.pytest.org/en/latest/reference/reference.html#pytester
Package: pytest-pretty-terminal
pytest-pretty-terminalThispytestplugin makes the terminal output prettier and more verbose. Beside a bit formatting you will see the doc string and the parametrization of a test case printed to the terminal. Live logging is enabled by default.System requirementsDefining the system requirements with exact versions typically is difficult. But there is a tested environment:LinuxPython 3.8.12pip 21.2.4pytest 5.2.0Other versions and even other operating systems might work. Feel free to tell us about your experience.VersioningIn our versioning we followSemantic Versioning.Installing for usageThe Python Package Index takes care for you. Just use pip.python-mpipinstallpytest-pretty-terminalInstalling for developmentFirst, you need to get the sources.gitclonegit@github.com:devolo/pytest-pretty-terminal.gitThen you need to take care of the requirements.cdpytest-pretty-terminal
pythonsetup.pyinstallUsageTo activate the pretty output, you have to start pytest with the pretty option. Otherwise, the plugin is skipped.pytest--prettyCompatibility with other pytest pluginsThis plugin should not interfere with other plugins. In case of usingpytest-xdist, you will lose live logging, as xdist uses stdin/stdout for communicating with its workers.
Package: pytest-print
pytest-printAllows to print extra content onto the PyTest reporting. This can be used for example to report sub-steps for long
running tests, or to print debug information in your tests when you cannot debug the code.installpipinstallpytest-printThe plugin provides ability to print information during the tests runs.flags--printby default the module activates print when pytest verbosity is greater than zero, this allows to bypass this
and force print irrespective of the verbosity--print-relative-timewill print the relative time since the start of the test (display how long it takes to reach
prints)use casessub-step reportingFor tests that are long running this can provide a feedback to the end-user that what is just happening in the
background.deftest_server_parallel_requests(printer,tmpdir):printer("create virtual environment into{}".format(tmpdir))create_virtual_environment(tmpdir)printer("start server from virtual env")start_server(tmpdir)printer("do the parallel request test")parallel_requests()$py.test--vv=============================testsessionstarts==============================platformlinux--Python3.6.4,pytest-3.5.0,py-1.5.3,pluggy-0.6.0
collecting...collected1item

test_printer_progress.py::test_server_parallel_requestscreatevirtualenvironmentstartserverfromvirtualenvdotheparallelrequesttestPASSED[100%]===========================1passedin0.02seconds===========================
Package: pytest-priority
Pytest-Priority为用例添加优先级标记，并支持按优先级筛选用例执行安装方法pipinstallpytest-priority使用方法标记优先级# test_demo.pyimportpytest@pytest.mark.priority('p0')deftest_a():pass@pytest.mark.priority('p1')deftest_b():pass@pytest.mark.priority('p2')deftest_c():pass筛选测试用例,例如运行优先级为p0和p1的用例pytesttest_demo.py--priority=p0--priority=p1
Package: pytest-profiles
pytest_profilespytest plugin to create configuration profiles.Installation$pipinstallpytest_profilesUsageDefine your pytest configurations in aconftest.py.# conftest.pyfrompytest_profilesimportprofilefrom_pytest.configimportConfig@profile(autouse=True)defdefault(config:Config)->None:"""sets pytest configuration optionswhich are always applied (autouse=True)"""config.option.verbose=1@profiledefcustom(config:Config)->None:"""sets pytest configuration optionsonly when `--profile custom` argument is applied."""config.option.newfirst=Trueconfig.option.failedfirst=Trueactivate profiles by passing command line arguments to pytest# pytest runs with verbosity=1 by default$pytest# pytest runs new and failed tests first$pytest--profilecustomIt is also possible to define dependencies between profiles# conftest.pyfrompytest_profilesimportprofilefrom_pytest.configimportConfig@profiledefbase(config:Config)->None:config.option.newfirst=Trueconfig.option.failedfirst=True@profile(uses=["base"])defsub(config:Config)->None:"""the sub profile also includes the configuration of the base profile."""config.option.verbose=1seeconftest.pyfor more examples.
Package: pytest-progress
pytest-progress is a plugin forpy.testthat allows to
print the test progress like number of tests Passed , Failed, Skipped and also
instant test failure messages.RequirementsYou will need the following prerequisites in order to use pytest-progress:Python 2.7, 3.4 or 3.5pytest 2.9.0 or newerInstallationTo install pytest-progress:$ pip install pytest-progressThen run your tests with:$ py.test --show-progressIf you would like more detailed output (one test per line), then you may use the verbose option:$ py.test --verboseExamplesTo run the pytest with progress:$ py.test --show-progress test_progress_report.py
$ py.test --showprogress test_progress_report.pyTo run tests in verbose mode:$ py.test --show-progress --verbose test_progress_report.py
$ py.test --showprogress --verbose test_progress_report.py
Package: pytest-prometheus-pushgateway
pytest-prometheus-pushgatewayPytest report plugin forPrometheus PushGatewayAllow to send reports test results to a Prometheus PushGateway.installationpip install pytest-prometheus-pushgatewayConfigure via env varPROMETHEUS_PUSHGATEWAY_URL=""
PROMETHEUS_PUSHGATEWAY_JOB=""Basic Auth:PROMETHEUS_PUSHGATEWAY_BASIC_AUTH="true"
PROMETHEUS_PUSHGATEWAY_USERNAME=""
PROMETHEUS_PUSHGATEWAY_PASSWORD=""Optional:PROMETHEUS_PUSHGATEWAY_METRIC_PREFIX=""
PROMETHEUS_PUSHGATEWAY_EXTRA_LABEL="{'test':'value','test1':'value1'}"Add labels via hookdef pytest_metrics_add_labels(session: Session, exitstatus: Union[int, ExitCode]) -> str:
    return {"html_report": report_url}Add option to send metricspytest --metricsDevChange versioneditpytest_prometheus_pushgateway/__init__.pycommitgit commit -m "v0.1.0"taggit tag v0.1.0Build packagepython setup.py sdist bdist_wheel
pip install twine
twine upload dist/*TestCreate endpoint onrequestbinand add the url to PROMETHEUS_PUSHGATEWAY_URL to set_env fixture into conftest.pyUse the runner in Pycharm.pytest test_pytest_prometheus.py::TestPrometheus