Saravanan666/pypi-org huggingface dataset:
Package: pytest-network
pytest-networkA simple pytest plugin to disable network on socket level.Installation$ pip install pytest-networkUsagepytest-networkhas a flag--disable-networkthat will raise an error
if tests will try to usesocket.socket.connectYou can use it directly like:$ python3 -m pytest --disable-networkor add this flag as the default behavior in yourpytest.ini:[pytest]addopts=--disable-networkAlso you can directly disable network:importrequestsdeftest_network_request_raises_error(disable_network):response=requests.get('https://github.com')# this will raise an exceptionassertresponse.status_code==200or directly enable (if you have default--disable-networkflag):importrequestsdeftest_network_request_is_ok(disable_network):response=requests.get('https://github.com')assertresponse.status_code==200# this will passDevelopmentTo setup development environment you must first create a virtual environment.
For example:$ python3.8 -m venv <venv-name>After that install all requirements:$ pip install -r requirements.txtAnd install plugin itself (inside project directory and virtual environment):$ pip install -e .Check that tests are running:$ make testContributingWe would love you to contribute to our project. It's simple:Create an issue with bug you found or proposal you have.
Wait for approve from maintainer.Create a pull request. Make sure all checks are green.Fix review comments if any.Be awesome.Here are useful tips:You can run all checks and tests with make check.
Please do it before TravisCI does.We useBestDoctor python styleguide.
Sorry, styleguide is available only in Russian for now.We respectDjango CoC.
Make soft, not bullshit.
Package: pytest-nginx
pytest-nginxpytest-nginx is a pytest plugin, that allows you to test code, which requires
communicating with a full-fledged web server. Custom fixtures can be made which
manage the content of the server root directory.UsageThe plugin contains one fixture:nginx_proc- session scoped fixture, which manages the nginx daemon with
the most basic configuration for serving static files.nginx_php_proc- session scoped fixture, which manages the nginx daemon
and the php-fpm daemon, both configured to work together.All fixtures take the name of a fixture managing the server root directory. In
the simplest case it is an empty temporary directory managed with thetmpdir_factorybuilt-in fixture:frompytest_nginximportfactories@pytest.fixture(scope="session")defnginx_server_root(tmpdir_factory):returntmpdir_factory.mktemp("nginx-server-root")nginx_proc=factories.nginx_proc("nginx_server_root")To manage the served content, you can create additional module or
function-scoped fixtures on top ofnginx_proc:@pytest.fixture(scope="module")defnginx_hello_world(nginx_proc):f=open(os.path.join(nginx_proc.server_root,"index.html"),"w")f.write("Hello world! This is pytest-nginx serving on host{}, port{}.".format(nginx_proc.host,nginx_proc.port))f.close()returnnginx_procConfigurationYou can define your settings in three ways: with fixture factory arguments,
with command line options and withpytest.iniconfiguration options. These
settings are handled in the following order:Fixture factory argumentsCommand line optionspytest.iniconfiguration optionsFixture factory argumentCommand line optionpytest.ini optionDefaulthost–nginx-hostnginx_host127.0.0.1port–nginx-portnginx_portrandomnginx_exec–nginx-execnginx_execnginxnginx_params–nginx-paramsnginx_params“”nginx_config_template–nginx-config-templatenginx_config_templateauto-generatedphp_fpm_exec–php-fpm-execphp_fpm_execphp-fpmphp_fpm_params–php-fpm-paramsphp_fpm_params“”php_fpm_config_template–php-fpm-config-templatephp_fpm_config_templateauto-generatedExamples showing how to specify the port number:Pass it as an argument to the factory function:nginx_proc=factories.nginx_proc(port=8888)Use the--nginx-portcommand line option when running pytest:pytest ./tests --nginx-port=8888Add thenginx_portoption to thepytest.inifile:[pytest]nginx_port=8888
Package: pytest-nginx-iplweb
pytest-nginxpytest-nginx is a pytest plugin, that allows you to test code, which requires
communicating with a full-fledged web server. Custom fixtures can be made which
manage the content of the server root directory.UsageThe plugin contains one fixture:nginx_proc- session scoped fixture, which manages the nginx daemon with
the most basic configuration for serving static files.nginx_php_proc- session scoped fixture, which manages the nginx daemon
and the php-fpm daemon, both configured to work together.All fixtures take the name of a fixture managing the server root directory. In
the simplest case it is an empty temporary directory managed with thetmpdir_factorybuilt-in fixture:frompytest_nginximportfactories@pytest.fixture(scope="session")defnginx_server_root(tmpdir_factory):returntmpdir_factory.mktemp("nginx-server-root")nginx_proc=factories.nginx_proc("nginx_server_root")To manage the served content, you can create additional module or
function-scoped fixtures on top ofnginx_proc:@pytest.fixture(scope="module")defnginx_hello_world(nginx_proc):f=open(os.path.join(nginx_proc.server_root,"index.html"),"w")f.write("Hello world! This is pytest-nginx serving on host{}, port{}.".format(nginx_proc.host,nginx_proc.port))f.close()returnnginx_procConfigurationYou can define your settings in three ways: with fixture factory arguments,
with command line options and withpytest.iniconfiguration options. These
settings are handled in the following order:Fixture factory argumentsCommand line optionspytest.iniconfiguration optionsFixture factory argumentCommand line optionpytest.ini optionDefaulthost–nginx-hostnginx_host127.0.0.1port–nginx-portnginx_portrandomnginx_exec–nginx-execnginx_execnginxnginx_params–nginx-paramsnginx_params“”nginx_config_template–nginx-config-templatenginx_config_templateauto-generatedphp_fpm_exec–php-fpm-execphp_fpm_execphp-fpmphp_fpm_params–php-fpm-paramsphp_fpm_params“”php_fpm_config_template–php-fpm-config-templatephp_fpm_config_templateauto-generatedExamples showing how to specify the port number:Pass it as an argument to the factory function:nginx_proc=factories.nginx_proc(port=8888)Use the--nginx-portcommand line option when running pytest:pytest ./tests --nginx-port=8888Add thenginx_portoption to thepytest.inifile:[pytest]nginx_port=8888
Package: pytest-ngrok
pytest integration forngrok.ioInstallationfrom PyPipipinstallpytest-ngrokor from gitpipinstall-egit+https://githib.com/Apkawa/pytest-ngrok.git#egg=pytest-ngrokUsageimportpytestfromurllib.errorimportHTTPErrorfromurllib.requestimporturlopendeftest_ngrok(ngrok,httpserver):httpserver.expect_request("/foobar").respond_with_data("ok")remote_url=ngrok(httpserver.port)asserturlopen(remote_url+"/foobar").read()==b'ok'deftest_ngrok_context_manager(ngrok,httpserver):# example local serverhttpserver.expect_request("/foobar").respond_with_data("ok")withngrok(httpserver.port)asremote_url:_test_url=str(remote_url)+'/foobar'asserturlopen(_test_url).read()==b'ok'# Connection closespytest.raises(HTTPError,urlopen,_test_url)Withpytest-djangocan use fixturelive_server_ngrokdeftest_server(live_server_ngrok):assertlive_server_ngrok.url.endswith('ngrok.io')ContributingInitializepython-mvenv/tmp/.venv/pytest-ngroksource/tmp/.venv/pytest-ngrok/activate
pipinstall-rrequirements-dev.txtRun testspytest
toxUpdate versionpythonsetup.pybumpversionPublish pypipythonsetup.pypublish
Package: pytest-nhsd-apim
pytest-nhsd-apimA pytest extension for NHSDigital's API Mangement suite.InstallationIn your project's virtual environmentpoetry add pytest-nhsd-apimor if using pip directlypython -m pip install pytest-nhsd-apimUsagecreate a python test filewrite a test using our custom authentication markers!enjoy!?Testingrunmake testto run test examples, located in this repoafter creating your file you can use the plugin as:python -m pytest -p pytest_nhsd_apim test_nhsd_apim.py -s --apigee-proxy-name=<your-proxy-name>Available toolsWhen installing this library in your project you can access some very handy tools, including our platform authenticators and our apigee api wrapper library.AutheticatorsWe present a variety of authenticators including AuthorizationCodeAuthenticator, ClientCredentialsAuthenticator and TokenExchangeAuthenticator. The way of using them is simple. First you create the configuration object which will validate that your coniguration is correct on creation using pydantic, then pass the config to the authenticator and call get_token() on it.frompytest_nhsd_apim.identity_serviceimportClientCredentialsConfig,ClientCredentialsAuthenticatorconfig=ClientCredentialsConfig(environment={APIGEE_ENVIRONMENT},identity_service_base_url={BASE_URL},client_id={CLIENT_ID},jwt_private_key={PRIVATE_KEY_PEM},jwt_kid={KEY_ID},)authenticator=ClientCredentialsAuthenticator(config=config)token=authenticator.get_token()For a more detailed implementation on the rest of the authenticators please refer to the exampleshere.Apigee APIsWe also present a variety off Apigee APIs with the benefit of a fully authenticated Apigee client ready to use. Just remember to export the following variables# If you want the client to authenticate you...exportAPIGEE_NHSD_NONPROD_USERNAME={my_username}exportAPIGEE_NHSD_NONPROD_PASSWORD={my_password}exportAPIGEE_NHSD_NONPROD_OTP_KEY={my_otp}# Or alternatively, if you already have a token you can pass it and the client will use it.exportAPIGEE_ACCESS_TOKEN={access_token}#NOTE: in case both sets of credentials are defined, the username and password take presedence, this is so the Apigee client can keep itself authenticated all the time.frompytest_nhsd_apim.apigee_apisimportApigeeNonProdCredentials,DeveloperAppsAPIconfig=ApigeeNonProdCredentials()client=ApigeeClient(config=config)apps=DeveloperAppsAPI(client=client)print(apps.list_aps('lucas.fantini@nhs.net'))The APIs we offer at the moment are:APIMethodsDocumentationDeveloperAppsAPIhereOverviewApiProductsAPIhereOverviewDebugSessionsAPIhereOverviewAccessTokensAPIhereOverviewFor a more detailed implementation of the available APIs please refer to the testshere.
We will keep adding APIs with time, if you are looking for a particular APIs not listed above please feel free to open a pull request and send it to us.
Package: pytest-nice-parametrize
Nice ParametrizeUsage example:fromnice_parametrizeimportparametrize@parametrize(["a","b","result"],{"equal":[1,1,True],"unequal":[1,2,False],})defmy_test(a,b,result):assert(a==b)isresultA small Python snippet that makespytest.mark.parametrizea little nicer to use.pytest.mark.parametrizehas a nice feature calledidsthat allows you to name your argument lists.
This is very useful for stating the intention of the tested case.
But the problem is that the names are given in a separate parameter,ids,
so it is not easy to see at a glance which arguments match which case:importpytest@pytest.mark.parametrize(["a","b","result"],[[1,1,True],[1,2,False]],ids=["equal","unequal"])defmy_test(a,b,result):assert(a==b)isresultThis might get very cumbersome with a long parameter list and a lot of cases.
So instead,nice_parametrizeallows you to pass in adictthat
maps between the ID of the argument list to the list itself.
This way it is clear which case match which arguments,
and it is easier to understand and debug your test.Also supports additional keyword arguments to be passed to the underlyingpytest.mark.parametrize.
Package: pytest-nlcov
pytest_nlcovWithpytest_nlcovyou can check the test coverage of new lines only. It will
check git for added and modified lines and will compute the coverage
just for those linesInstallationpipinstallpytest_nlcovNote:pytest_covis required and will be automatically installed when it
is not installed yet.Usage with pytestWhenpytest_nlcovis installed, it will be discovered by pytest and executed as last step to
show you the test coverage of new lines.pytestTwo option can be given:revisionfail thresholdRevisionDefault, the new lines are based on the git diff with master. You can specify other revisions.pytest--nlcov-revisionmainFail ThresholdOptionally you can add a threshold to fail the tests when the coverage is below the threshold.pytest--nlcov-fail-under0.6Usage without pytestpytest_nlcovcan be run without pytest. Therefor you have to runcoveragefirst, becausepytest_nlcovneeds its coverage data.coverage
nlcovOptionally a revision can be givennlcovmain
Package: pytest-nocustom
Pytest-nocustom============Allows you to run all tests marked without custom markersRequirements============A recent version of pytest is required (>= 2.3.4).Running all test without custom markers------------------------------------In the pytest.ini file, each marker's description should start with 'custom'[pytest]markers =leak: custom - leak testsmanual: custom - tests that should be run manuallyinprogress: custom - tests that are yet to be finishedlong_running: custom - long running or heavy hittersThen just run py.test with the ``--nocustom`` option to enable.This will allow you to skip tests that you've marked, but not tests that usemarkers that pytest has provided (such as django_db or tryfirst, trylast, etc.)
Package: pytest-nogarbage
The purpose of this plugin is ensuring that portions of your Python code do not produce garbage or manually invoke garbage collection.When thenogarbagepytest fixture is added to a test, it will cause an error under the following conditions:Garbage was collected after the test was run (circular references were remaining after the test was broken down).Garbage was explicitly collected  (gc.collect()) during the test.  Automatic garbage collection sweeps are disabled during the test.You should use this plugin when:You intend to run a program with garbage collection disabled in production.You wish to verify elimination of garbage collection overhead produced by frequently called functions.RequirementsPython 3.7+This plugin is only tested against CPython.InstallationYou can install “pytest-nogarbage” viapipfromPyPI:$ pip install pytest-nogarbageUsageAdd thenogarbagefixture to your test to ensure it does not produce garbage:def test_circular(nogarbage):
    l1 = []
    l2 = [l1]
    l2.append(l1)
    # ERROR: Garbage collected after test.

def test_collect(nogarbage):
    import gc
    gc.collect()
    # ERROR: Garbage collected during test.Recommended ReadingIf you are interested in optimizing CPython garbage collection, thegc docsandCPython Garbage Collection devguideare excellent resources.LicenseDistributed under the terms of theMITlicense, “pytest-nogarbage” is free and open source software.
Package: pytest-nose-attrib
pytest-nose-attribThepytest-nose-attrib_ plugin serves two purposes. It adds lets to use
nose attribites marks with @attrib decorator. And to pick the tests with
that attribues. It could be usefull when running nose tests with pytest.InstallationInstall the plugin with:pip install pytest-nose-attribUsage examplesTo use the plugin, the-aCLI argument has been
provided.Using pytest-nose-attrib, only tests marked with method='get' can be run using:$ py.test -a "method=get"LICENSEThis code falls under theMIT License.
Please note that some files or content may be copied from other places
and have their own licenses. Dependencies that are being used to generate
the databases also have their own licenses.
Package: pytest_notebook
pytest-notebookApytestplugin for regression testing and regeneratingJupyter Notebooks.PurposeThe purpose of the plugin is to ensure that changes to the python
environment (e.g. updating packages), have not affected the outputs
of the notebook. If the notebook has changed, this plugin can also
regenerate the notebooks, saving the new outputs.FeaturesRecognise, collect, execute (optionally output) then diff input vs. outputJupyter Notebooks.Provides clear and colorized diffs of the notebooks (usingnbdime)Regenerate failing notebooks.Integration withcoverageandpytest_cov.A well defined API allows notebook regression tests to be run:Using the pytest test collection architecture.As a pytest fixtures (nb_regression.check(filename)).Using thepytest_notebookpython package.All stages are highly configurablevia:The pytest command-line interface.The pytest configuration file.The notebook and cell level metadata.Post-processor plugin entry-points, allow for customisable modifications of the notebook,
including source code formatting withblackInstallationTo install fromConda(recommended):condainstall-cconda-forgepytest-notebookTo installviapipfromPyPI:pipinstallpytest-notebookTo install the development version:gitclonehttps://github.com/chrisjsewell/pytest-notebook.cdpytest-notebook
pipinstall--upgradepip
pipinstall-e.# pip install -e .[code_style,testing,docs] # install extras for more featuresUsageSee the documentation at:http://pytest-notebook.readthedocs.io/If you want to test some sample notebooks, add the--nb-test-filesflag:gitclonehttps://github.com/chrisjsewell/pytest-notebookcdpytest-notebook/examples
pipinstallpytestipykernelpytest-notebook
pytest--nb-test-files*.ipynbYou should seesuccess.ipynbpassed the test andfail.ipynbfailed the test.You can regenerate the outputs offail.ipynbwith the--nb-force-regenflag:pytest--nb-test-files--nb-force-regen*.ipynbContributingContributions are very welcome.The following will discover and run all unit test:pipinstall-e.[testing]pytest-vCoding Style RequirementsThe code style is tested usingflake8,
with the configuration set in.flake8,
and code should be formatted withblack.Installing withpytest-notebook[code_style]makes thepre-commitpackage available, which will ensure these tests are passed by reformatting the code
and testing for lint errors before submitting a commit.
It can be setup by:cdpytest-notebook
pre-commitinstallOptionally you can runblackandflake8separately:black.
flake8.Editors like VS Code also have automatic code reformat utilities, which can adhere to this standard.LicenseDistributed under the terms of theBSD-3license,pytest-notebookis free and open source software.IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Acknowledgementsnbdimenbval
Package: pytest-notification
Pytest-notificationA plugin for pytest that sends notifications if a--notifyflag is passed
to pytest on the command line. It plays sounds when a--soundor--play-soundflag is passed.The notifications and sounds are different depending whether the test run
has passed or failed.The messages and sounds are only played when the flags are passed. This allows
you to turn it on only for those tests for which you expect a long time is
needed.Alternativespytest-notifieralways sends
a notification. It can be turned of with--notify-off. This is a
fundamentally different design choice, which is why this package was created.
Pytest-notifier has been around for a long time and is still being actively
maintained. It does not support playing sounds, but it does support Mac OS X
notifications.Usageoptionusage--notifySends a desktop notification when pytest is finished. (Only implemented on Linux. Requires the ‘notify-send’ program in PATH on Linux.--sound,--play-soundPlays a sound when pytest is finished. (Only implemented on Linux and Macintosh systems).--disturbshorthand for--notify--soundInstallationpytest-notification can be installed withpip installpytest-notification.LinuxOn Linux notifications are supported via thenotify-sendprogram. On Debian,
Ubuntu and derived distros this is available in thelibnotify-binpackage.On Linux sound is supported via thepaplayprogram. On Debian, Ubuntu and
derived distros this available in thepulseaudio-utilspacakge.The installation for Ubuntu should be:sudoaptupdatesudoaptinstalllibnotify-binpulseaudio-utilspipinstallpytest-notificationMac OS XOn Mac OS X sound is implemented via theafplayprogram, which should be
installed by default. Since I do not own a mac I can not test this feature.
pull requests are welcome.On Mac OS X notifications are not supported.
Alternatively you could take a look atpytest-notifier, which does support Mac OS X.WindowsWindows is not supported.ContributingPull requests for improved Mac and Windows support are welcome. As well as ideas
and other pull requests. Simply create a new issue or PR on thegithub page.Windows  supportIn theory thewinsoundmodule could be used to
play sounds, but this only supports wave files. These are very big and
cumbersome to distribute. I have not actively looked for a way to create a
message on windows. There will probably be some powershell command that can
pull this off. Pull requests are welcome.
Package: pytest-notifier
Apytestplugin to notify test result on Linux and OS X.RequirementsLinuxMake surenotify-sendis exists in$PATH,
which comes fromlibnotify.OS XOS X 10.8 and higher is required.Optionally, you could installterminal-notifierto avoid Script Editor being opened when notification icon is clicked.InstallationYou can installpytest-notifierviapipfromPyPI:$ pip install pytest-notifierUsageOnce installed, notification will be shown after each test run.By using withpytest-watch,
you can get continous feedback during development:$ ptwYou can use--notifier-offflag to disable notification:$ pytest --notifier-offLicenceDistributed under the terms of theMITlicense,pytest-notifieris free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest_notify
=============pytest-notify=============.. image:: https://travis-ci.org/Shir0kamii/pytest-notify.svg?branch=master:target: https://travis-ci.org/Shir0kamii/pytest-notify:alt: See Build Status on Travis CIGet notifications when your tests endsSimply install it and each time a pytest invocation ends, you'll receive adesktop notification.The installation is pretty simple::$ pip install pytest-notifyLicense-------Distributed under the terms of the `MIT`_ license, "pytest-notify" is free and open source softwareIssues------If you encounter any problems, please `file an issue`_ along with a detailed description.----This `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template.
Package: pytest-notimplemented
pytest-notimplementedA pytest plugin providing a marker for not implemented features and tests.@mark.notimplementedThenotimplementedmarker is designed to be used for tests which should fail because
the feature is not yet implemented.As tests on not implemented features should fail, it is just syntatic sugar for a
standardxfailmarker with a "Not implemented" message.frompytestimportmark@mark.notimplementeddeftest_foo(foo):assertfoo.baz()@mark.xfail("Not implemented")deftest_bar(bar):assertbar.baz()@mark.notwrittenThenotwrittenmarker is is designed to be used for tests which are declared but not
defined. Those kind of tests are just placeholders to help the developer remember that
the behavior must be tested. And that marker helps on it.As not written tests (or tests not finished to write) are impredictable, they must be
skipped. That marker is just syntatic sugar for a standardskipmarker with a
"Not written" message.frompytestimportmark@mark.notwrittendeftest_foo(foo):pass@mark.skip("Not written")deftest_bar(bar):pass