Saravanan666/pypi-org huggingface dataset:
Package: pytest-expect-test
A fixture to support expect tests (golden tests) in pytestThis code was mostly copied fromezyang/expecttestwho wrote an implementation for unittest.InstallationYou can install “pytest-expect-test” viapipfromPyPI:$ pip install pytest-expect-testUsageStart by writing your test, printing out any interesting output, and then calling expect with an empty string# Function we are testingdefcumulative_sum(nums):cum_sum=0result=[]fornuminnums:result.append(num+cum_sum)cum_sum+=numreturnresultdeftest_simple(expect):print(cumulative_sum([2,3,5]))expect("""""")print(cumulative_sum([1,5,9]))expect("""""")Then run:$ pytestNote that the test fails because we expected nothing to be printed (e.g. we passed an empty string to the expect function), but there was some text that was printed.We can automatically fix these tests by running:$ EXPECTTEST_ACCEPT=1 pytestOur test will then be updated to look like:deftest_simple(expect):print(cumulative_sum([2,3,5]))expect("""\[2, 5, 10]
""")print(cumulative_sum([1,5,9]))expect("""\[1, 6, 15]
""")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-expect-test” is free and open source softwareThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-explicit
Pytest-ExplicitSome tests you just don't want to runHey, I get it. Sometimes we write tests, but we don't actually want to wait
for them to finish executing. Whether they're slow tests, they need some
dependencies you don't have, or they aren't related to the work you
do, there's some tests that just weren't meant to be run by devs in the age
of CI/CD platforms. That's wherepytest-explicitcomes in.This plugin allows developers to specify test markers that should be ignored
by default when runningpytest, but also quickly bypass this behaviour
for CI/CD. Just add a--run-allflag to your pytest command for your test
pipeline, and this plugin won't skip anything!ConfiguringIf all you want to do is skip slow tests by default, you can stop reading
now. Out-of-the-box,pytest-explicitwill make any test markedslowrequire you to pass the--run-slow(or--run-all) for them to take
up precious developer time.Need more ignored tests? Just add theexplicit-onlyoption to your
pytest config file, andpytest-explicitwill pick up the markers
specified and dynamically add--run-<marker>CLI options to pytest. Here's
a samplesetup.cfgfile below![tool:pytest]markers=slow:Marks a slow testmemory_intensive:Marks a test that needs at least 16 gb RAM to runsmoke:Marks a test that gives early alert to the health of the apptestpaths=testsexplicit-only=slowmemory_intensiveWith this configuration file, any test marked with eitherslowormemory_intensivewon't run unless the appropriate CLI flags are passed!
Package: pytest-explorer
pytest-explorerFast terminal ui pytest explorer.Bench test collecting on aiohttp testsrepo:https://github.com/aio-libs/aiohttpwith pytest, coverage was turned offcommand:time pytest --copytest --co  1.21s user 0.06s system 99% cpu 1.278 totalwith pytexpcommand:time pytexp -cpytexp -c  0.08s user 0.01s system 83% cpu 0.104 totalBuild from sourceInstall rust (Minimum supported version: 1.67)https://www.rust-lang.org/tools/installgit clone https://github.com/antonguzun/pytest-explorer.gitcd pytest-explorerbuild with cargocargo build --releaseset softlinkls -s $(pwd)/target/release/pytexp /usr/bin/pytexpUsageactivate virtual envsource ./venv/bin/activateset PYTHONPATH if neededstart pytexp in directory with testsKnown LimitationsTest collecting:parametrized tests are not implementedinheritanced tests in classes are not implementedDeep cross-file ast analysis is needed
Package: pytest-external-blockers
A pytest outcome for tests you dont run for external/environmental reason.examples of such reasons reasons are:lack of access to a bugtracker telling you what tests apply
for the current version of software under testlack of access to a backend service providing essential details for the tests in questionissue in a bugtracker is unresolvedfailure of the internet connectioninstall$ pip install pytest-external-blockersuseimportosimportpytestfrom.issuesimportget_trackerpytestmark=pytest.mark.skipif("BUGTRACKER"inos.environ,reason="no bugtracker configured")@pytest.fixture(scope="session")defbugtracker():try:returnget_tracker():exceptException:pytest.block("bugtracker unavailiable")@pytest.fixture(autouse=True)def_block_unresolved(request,bugtracker):issue=request.node.getmarker('issue')ifissueisnotNone:forissue_idinissue.args:ifbugtracker.is_unresolved(issue_id)pytest.block("{issue_id}was not resolved".format(issue_id))
Package: pytest-extra-durations
pytest-extra-durationsGet more info about the speed of your test suite.It works with pytest-xdist too.InstallationYou can install "pytest-extra-durations" viapip:pipinstallpytest-extra-durationsUsageThis plugin provides three types of information.The sum of all tests/setup/teardown durationsThis can give you more info than the total time displayed by pytest because it's
not influenced by the number of workers in pytest-dist, or the collection time.Exemple:============== Sum of all tests durations ===============
1.95sThis will be displayed all the time and can't be turned off unless you
uninstall this plugin.The sum of all the tests durations of a moduleThis will tell you how much time it took to execute all the tests in a given file.
The API is similar to the one of--durationsin the Pytest CLI.pytest--modules-durations=4./path/to/test/directorygives:=============== slowest 4 modules durations =============
1.17s tensorflow_addons/activations/tests/sparsemax_test.py
0.28s tensorflow_addons/activations/tests/gelu_test.py
0.10s tensorflow_addons/activations/tests/softshrink_test.py
0.09s tensorflow_addons/activations/tests/rrelu_test.pyThe sum of all the tests durations of a test functionA test function can produce multiple tests, that can be executed on different workers
too. This will sum the durations of all tests, setups and teardown produced by
a single test function, and report the slower ones.The API is similar to the one of--durationsin the Pytest CLI.pytest--functions-durations=4./path/to/test/directorygives:============ slowest test functions =============
0.99s tensorflow_addons/activations/tests/sparsemax_test.py::test_gradient_against_estimate
0.17s tensorflow_addons/activations/tests/gelu_test.py::test_same_as_py_func
0.09s tensorflow_addons/activations/tests/softshrink_test.py::test_same_as_py_func
0.08s tensorflow_addons/activations/tests/gelu_test.py::test_gelu
0.08s tensorflow_addons/activations/tests/rrelu_test.py::test_theoretical_gradientsTODO:Integration with line_profilerLicenseDistributed under the terms of theMIT_ license, "pytest-extra-durations" is free and open source software
Package: pytest-extra-markers
pytest-extra-markersApytestplugin to dynamically skip tests based onmarksInstallationpipinstallgit+https://github.com/iwishiwasaneagle/pytest-extra-markers@masterUsageConsider the following test scenario:importpytest# Adeftest_speedy_unit_test():...# B@pytest.mark.integrationdeftest_integration_test():...# C@pytest.mark.slow_integrationdeftest_super_slow_integration_test():...You want to quickly run all your quick unit tests before committing. Then, after you are happy that the changes haven't messed up any unit tests you want to run the integration tests, and then after that yoursuperslow integration tests. This would look like:pytest
pytest--only-integration
pytest--only-slow-integrationIn theory, your quick unit tests give you feedback instantly about anything that's been
broken by your changes. After that, the slower integration tests can be run to have a
more broad check.Author's noteMy use cases is mainly for simulations, so the--only-slow-integrationflag
can sometimes take tens of minutes to run whereas an integration test might take
milliseconds. Therefore, I made the distinction between the two.CLI FlagsFlagDescription--with-integrationRun all unit + integration tests--with-slow-integrationRun all unit + slow integration tests--only-integrationOnly run integration tests--only-slow-integrationOnly run slow integration testsTodoPublish to PyPi
Package: pytest-fabric
RequirementsPython 2.7Fabric 1.14.0TODOs (will make into issues eventually)Only runs one host right now if usingfabric_hostfixture (Support multiple container)Usagefabric_hostwill set up the fabric environment to be SSHable
The object is adocker.models.containers.Containerobject.From here, users should be able to exec into the container to check
things like the image files and such.Note: This should work for docker-machine or dockerfromfabric.apiimportexecutefrom.fabric_tasksimportcreate_readmedeftest_fabric_task_executes(fabric_host):execute(create_readme)ls_results=fabric_host.exec_run('ls /tmp/')assertls_results[1].strip()=='README.rst'Note: pytest-capture does not like when we try to actually write to stdout like in fabric so make sure to add-sto your pytest args
Package: pytest-factoryboy-fixtures
pytest-factoryboy-fixturesWrites pytest fixtures for FactoryBoy with type hinting. The hints allow for proper code completion in your tests when using PyCharm.Usagepytest-factoryboy-fixtures [comma seperated class names]Add the generated code to yourconftest.py.Example>>> pytest-factoryboy-fixtures FirstClass,SecondClass@fixturedeffirst_class()->FirstClass:returnFirstClassFactory()@fixturedeffirst_class_factory()->Union[Type[FirstClass],Type[FirstClassFactory]]:returnFirstClassFactory@fixturedefsecond_class()->SecondClass:returnSecondClassFactory()@fixturedefsecond_class_factory()->Union[Type[SecondClass],Type[SecondClassFactory]]:returnSecondClassFactory
Package: pytest-factoryboy-state
pytestplugin to manage random state infactory_boy.—factory_boyuses randomness in order to generate its fuzzed values which makes it hard to reproduce tests which fail due to a fuzzed value.
This plugin shows the random state used by factory_boy (and faker) when there are test failurs. And allows to run the tests with a specific random state.FeaturesShow random state on test failures using cli option--show-stateor by setting an environment variable.Set random state through environment variable or with cli option--set-stateRequirementsPython > 3.7pytestfactory_boyInstallationYou can install “pytest-factoryboy-state” viapipfromPyPI:$ pip install pytest-factoryboy-stateUsageShow the random state of factoryboy on test failure with:$ pytest --show-stateOr by defining the environment variableSHOW_FACTORYBOY_STATEtoTrue.Rerun the tests with a given state:$ pytest --set-state=<factoryboy_state>You can also set the environment variableFACTORYBOY_STATEto the state and run pytest as usual.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-factoryboy-state” 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-failed-screen-record
Create a video of the screen when pytest failsThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesTODORequirementsYou need to install “scrot” via apt.$ sudo apt-get install scrotInstallationYou can install “pytest-failed-screen-record” viapipfromPyPI:$ pip install pytest-failed-screen-recordUsageTODOContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.Publish new version to PyPI`bash poetry build poetry publish `LicenseDistributed under the terms of theMITlicense, “pytest-failed-screen-record” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-failed-screenshot
pytest-failed-screenshot: pytest pluginFor UI automation test cases using selenium and appium, screenshots are
saved when they fail, and are attached to the report when allure is usedSupport helium, the webdriver process cannot be killed within a use caseinstallpip installpytest-failed-screenshotUsagecommand line:pytest--screenshot={on:off}--screenshot_path={on:off:absolutepath}options:screenshot: Used to open plugin, default “off”screenshot_path:off: The default is ‘off’.The screenshot will not be saved and will only be attached to the allure report.on: The screenshots will be saved to the “./screenshot/%Y-%m-%d/” directory in the root path of the project.
If the directory has historical screenshots, the historical screenshots will be archived, moved to the
“./screenshot/history/%Y-%m-%d/{times}” directory, and attached to the allure reportAbsolute path: The screenshot will be saved in that path and attached to the report.DemoThe driver instances of selenium and appium must be transferred by a
fixture.importpytestfromseleniumimportwebdriver@pytest.fixture()definit_driver():driver=webdriver.Chrome()yielddriverdriver.close()driver.quit()deftest_login_success(init_driver):init_driver.get("https://github.com/fungaegis/pytest-failed-screenshot")assertFalse# helium demo@pytest.fixture()definit_helium():yieldNonekill_browser()@pytest.mark.usefixtures("init_helium")deftest_helium_demo():start_chrome("https://github.com/fungaegis/pytest-failed-screenshot")# The webdriver process cannot be killed within a use caseassertFalsecommand:pytest--screenshot=on--screenshot_path=ontip: Support the use of pytest-xdist togetherlogv1.0.1Support helium for screenshots , solve the problemhttps://github.com/fungaegis/pytest-failed-screenshot/issues/1v1.0.2Update the readme and add demo
Package: pytest-failed-to-verify
A pytest plugin that helps better distinguishing real test failures from setup flakiness.FeaturesRe-running only the setup-phase on failureAdditional test-outcome:FAILED_TO_VERIFYif a failure happened in setup phase and prevented the actual test-logic from executing.InstallationYou can install the plugin using the following command:$pipinstallpytest-failed-to-verifyUsageBased on the existingpytest-rerunfailuresplugin we changed functionality to the following:Once installed the plugin provides an additional test outcomefailed-to-verifyin case a test fails in the setup-phase, additionaly you are able to control the amount of re-runs specifically for the setup phase:$pytest--rerun-setup1What’s the idea behind it?A pytest test consists of three phases (setup, call, teardown). Usually only the call phase contains the actual tested business logic and the outcome of this phase gives the most valuable result.The setup phase is used to provide the pre-conditions for the test and might be even larger than the test.Assuming that the flakiness of a test is evenly distributed between the lines of code a test is executing, having a large setup phase means an error due to flakiness is most likely to happen there. If that’s the case a test fails but is leaving you with no relevant test-outcome: the actual test did not happen.So if the setup fails the result of a test will befailed-to-verifyrather than failed.Additionally re-running only the setup phase is a mechanism that assures the code that is testing the actual business logic (call-phase) is actually executed and provides you a valid test outcome without suffering from a flaky setup phase.CreditsCredits tohttps://github.com/pytest-devas some of the code was taken and re-used from thepytest-rerunfailuresplugin. We used it as a starting point to implement the needed functionality.Known issuesBecause of the similarity it does not work well together with pytest-rerunfailures. If you still need to be able to rerun the complete test on case of an error you can do this as well using this plugin.ContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Thispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.
Package: pytest-faker
Faker_ integration with the pytest_ test runner==========================================.. image:: http://img.shields.io/travis/pytest-dev/pytest-faker.svg:target: https://travis-ci.org/pytest-dev/pytest-faker.. image:: https://img.shields.io/pypi/pyversions/pytest-qt.svg:target: https://pypi.python.org/pypi/pytest-qt/.. image:: http://img.shields.io/pypi/v/pytest-faker.svg:target: https://pypi.python.org/pypi/pytest-faker.. image:: http://img.shields.io/coveralls/pytest-dev/pytest-faker.svg:target: https://coveralls.io/r/pytest-dev/pytest-faker.. image:: https://readthedocs.org/projects/pytest-faker/badge/?version=latest:target: https://readthedocs.org/projects/pytest-faker/?badge=latest:alt: Documentation Statuspytest-faker adds Faker fixtures_ for easy use of Faker_ for your tests under pytest_ runner... _Faker: https://faker.readthedocs.io/.. _pytest: http://pytest.org/.. _fixtures: https://pytest.org/latest/fixture.htmlInstall pytest-faker-------------------------::pip install pytest-fakerExample-------An example of Faker_ and pytest_ integration.tests/test_faker.py:.. code-block:: pythonfrom faker.generator import Generatordef test_faker(faker):"""Faker factory is a fixture."""assert isinstance(faker, Generator)assert isinstance(faker.name(), str)License-------This software is licensed under the `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_.© 2015 Anatoly Bubenkov, Oleg Pidsadnyi and othersAuthors=======`Anatoly Bubenkov <bubenkoff@gmail.com>`_original idea and implementationThese people have contributed to `pytest-faker`, in alphabetical order:* `Jeff Widman <jeff@jeffwidman.com>`_* `Oleg Pidsadnyi <oleg.pidsadnyi@gmail.com>`_Changelog=========2.0.0------ Switch to a recent Faker (jeffwidman, bubenkoff)1.1.0------ Switch to a session scoped fixture (bubenkoff, thedrow)1.0.0------ initial release (bubenkoff)
Package: pytest-falcon
[![Build Status](https://travis-ci.org/yohanboniface/pytest-falcon.svg?branch=master)](https://travis-ci.org/yohanboniface/pytest-falcon) [![Pypi version](https://img.shields.io/pypi/v/pytest-falcon.svg)](https://pypi.python.org/pypi/pytest-falcon)# Pytest-FalconPytest helpers for the Falcon framework.## Install```pip install pytest-falcon```## UsageYou must create an `app` fixture to expose the Falcon application you want to test:```pythonimport falconimport pytestapplication = falcon.API()application.req_options.auto_parse_form_urlencoded = True@pytest.fixturedef app():return application```## Fixtures### clientAllows you to test your API:```pythonclass Resource:def on_post(self, req, resp, **kwargs):resp.body = json.dumps(req.params)application.add_route('/route', Resource())def test_post(client):resp = client.post('/route', {'myparam': 'myvalue'})assert resp.status == falcon.HTTP_OKassert resp.json['myparam'] == 'myvalue'```Response properties:- `body` the body as `str`- `json` the body parsed as json when the response content-type is 'application/json'- `headers` the response headers- `status` the response status, as `str` ('200 OK', '405 Method Not Allowed'…)- `status_code` the response status code, as `int` (200, 201…)
Package: pytest-fastest
Use SCM and coverage to run only needed testsThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesGathers coverage data from tests to track which tests call functions from which modules.Uses Git to track changes from a given commit to find the minimum set of tests that need to run to test new changes, then skips everything else.RequirementsPython 3.8+pytest 3.4.0+InstallationYou can install “pytest-fastest” viapipfromPyPI:$ pip install pytest-fastestUsagepytest-fastest can be set to run only tests:That test modules that have changed in Git,Tests that we don’t already have coverage data for, andTests that we’ve added or changed.In most common development workflows where you make short-lived branches
off a main “master” or “dev” branch, the amount of code that actually
changes while fixing a bug or writing a feature is usually just a small
portion of the whole codebase. Instead of running thousands of tests
after each change, pytest-fastest can identify the relevant ones that
thoroughly test your work but skip all the things youhaven’tchanged.To use it:Inpytest.ini, setfastest_committo the name of a Git commit to
compare your current work against. (You can also set or override it on the
command line with--fastest-commit). This is required if you want to
skip tests, which is the main reason for using this plugin.Use the command line argument--fastest-modeto choice the appropriate
running mode:all(default): Run all tests without collecting coverage data. This
emulates normal pytest behavior and has no effect on performance.skip: Skip tests that don’t need to be run, but update coverage data
on the ones that do run. This will usually be faster thanall, but
because collecting coverage information takes some time, as the number
of un-skippable tests grows very large it may actually become slower.gather: Don’t skip any tests, but do gather coverage data. This is
slower thanallbut can be used to seed the coverage cache.cache: This is a fast mode for fixing existing tests. It skips tests
but doesn’t update the coverage cache. It will never be slower thanalland will always be faster thanskip.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-fastest” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-fast-first
pytest fast firstWhen applying TDD, a key to successful, fast development is quick feedback. This
plugin tries to shorten the time to feedback by ordering fast tests before slower
ones.It measures the runtime of your tests and on subsequent sessions orders faster tests
before slower ones.Installationpipinstallpytest-fast-firstOptions--ff-inverse: Inverts the order (can be used to optimize the runtime of a test
suite when run with xdist)--ff-group-by-module: By default tests are just ordered by their runtime. If
you have module-scoped fixtures, this can help with better fixture reuse.`--ff-filepath: Use the given filepath to store/read results. Default: .pytest-runtimesState fileThe plugin creates the file.pytest-runtimesin which it stores the runtimes
in JSON format. If you want runtime-based ordering in CI builds, you can check
it in to your version control system (you will have to live with merge
conflicts though).License:MITCopyright 2021 Martin Vielsmaier & ContributorsPermission 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.ContributorsCem Yusuf Aydogdu: Custom filename option