Saravanan666/pypi-org huggingface dataset:
Package: pytest-lsp
pytest-lsp: End-to-end testing of language servers with pytestpytest-lspis a pytest plugin for writing end-to-end tests for language servers.It works by running the language server in a subprocess and communicating with it over stdio, just like a real language client.
This also meanspytest-lspcan be used to test language servers written in any language - not just Python.pytest-lsprelies on thepyglslibrary for its language server protocol implementation.See thedocumentationfor details on getting started.importsysimportpytest_lspfromlsprotocol.typesimport(CompletionParams,InitializeParams,Position,TextDocumentIdentifier,)frompytest_lspimport(ClientServerConfig,LanguageClient,client_capabilities,)@pytest_lsp.fixture(config=ClientServerConfig(server_command=[sys.executable,"-m","esbonio"],),)asyncdefclient(lsp_client:LanguageClient):# Setupresponse=awaitlsp_client.initialize_session(InitializeParams(capabilities=client_capabilities("visual-studio-code"),root_uri="file:///path/to/test/project/root/",))yield# Teardownawaitlsp_client.shutdown_session()asyncdeftest_completion(client:LanguageClient):result=awaitclient.text_document_completion_async(params=CompletionParams(position=Position(line=5,character=23),text_document=TextDocumentIdentifier(uri="file:///path/to/test/project/root/test_file.rst"),))assertlen(result.items)>0
Package: pytest-manual-marker
pytest-manual-markerPytest marker for marking manual tests. Adds options for collecting manual, automated (default) or both.Adds a different test outcome for manaual tests.Usage# content of test_manual.pyimportpytest@pytest.mark.manualdeftest_manual():"""this needs a opt in and will report manual as test status"""deftest_automated():"""this is a empty test just for shows"""collect only manual tests$pytest--collect-only-q--manualtest_manual.py::test_manual1/2 tests collected (1 deselected) in 0.00scollect only automated tests$pytest--collect-only-qtest_manual.py::test_automated1/2 tests collected (1 deselected) in 0.00scollect manual and automated tests$pytest--collect-only-q--include-manual# collect both manual and automated teststest_manual.py::test_manualtest_manual.py::test_automated2 tests collected in 0.00sInstallInstall this plugin::! pip install pytest-manual-marker
Package: pytestmar
first packagin attemptFree software: MIT licenseInstallationpip install pytestmarYou can also install the in-development version with:pip install https://github.com/Elamraoui-Sohayb/python-pytestmar/archive/master.zipDocumentationhttps://python-pytestmar.readthedocs.io/DevelopmentTo run all the tests run:toxNote, to combine the coverage data from all the tox environments run:Windowsset PYTEST_ADDOPTS=--cov-append
toxOtherPYTEST_ADDOPTS=--cov-append toxChangelog0.0.0 (2021-01-01)First release on PyPI.
Package: pytest-markdoctest
pytest-markdoctestA pytest plugin to doctest your markdown files.Help you test your python blocks in markdown indocteststyle, and make sure them behaving as you expected. This is especially helpful when dealing with markdown files containing many demo code, such asA project documented in markdown files,A tutorial on python written in markdown.Requirementspython>=3.7pytest>=6InstallationYou can install "pytest-markdoctest" viapipfromPyPI:$ pip install pytest-markdoctestUsageTo test a single markdown file:$pytestdocs/index.mdor test all markdown files in a directory:$pytestdocs/Your markdown file may contains REPL block (Read-Eval-Print-Loop).>>>2+35>>>print("Hello World!")HelloWorld!Or script block.importmathdefsquare(x):returnx*xVariables/functions defined before are accessible in subsequent blocks.>>>math.pow(2,2)4.0>>>square(2)4Markdoctest automatically find all code blocks tagged bypython,py,pyconand test them.Directives are allowed to control testing behavior.<!-- doctest: +SKIP -->```pythonimportmatha=3/0```Advanced UsageOption directivesScript blockLicenseDistributed under the terms of theMITlicense,
"pytest-markdoctest" is free and open source softwareAcknowledgementThispytestplugin was generated
withCookiecutteralong with@hackebrot'scookiecutter-pytest-plugintemplate.
Package: pytest-marker-bugzilla
bugzilla
plugin
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Environment :: Plugins
Classifier: Framework :: Pytest
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Utilities
Package: pytest-markers-presence
A simple plugin for easy staging your Python3 project’s structure ofPyTesttests.
Make the repository with your tests structured withAllureideology.FeaturesDynamical tests marking based on ‘tests’ subfoldersList not classified functionsList missed Allure BDD tags for test classes and functions (exclude fixtures and other incompatible objects)Assertions rewriting with Allure steps including attachments for complex objects:Pydantic BaseModelsdictionarieslistslong strings.Collecting of task tracker tickets with specified keywordEnable setting of fail exitcode when all session tests were skippedInstallationYou can install “pytest-markers-presence” viapipfromPyPI:$ pip install pytest-markers-presenceUsageThe–stagingoption is compatible with simple pytest run loop and could be used for dynamical tests marking.
The–staging-warningsoption just enables warnings for–stagingoption.The–assert-stepsoption is compatible with simple pytest run loop and could be used for assertions rewriting with
Allure steps.The–bdd-formatoption will not run your tests and it’s also sensible for errors in the pytest
collection step. If you are using as part of you CI process the recommended way is to run it after the default test run.The–all-skipped-failoption is compatible is simple pytest run loop
and could be used for enabling of fail exitcode setting when all session
tests were skipped.For example:script:pytestpytest –staging –all-skipped-failpytest –assert-stepspytest –bdd-formatExamples of ‘pytest’ run with provided options:$ pytest tests –staging –assert-steps======================= test session starts =======================(hidden for brevity)==================== 1 passed in 0.51 seconds =====================$ pytest –bdd-format======================= test session starts =======================(hidden for brevity)You should create test class(es) for your test function(s):
Test function: ‘test_function’, location: /path/to/test.pyYou should set BDD tag‘@allure.feature’ for your test class(es):
Test class: ‘TestClass’, location: /path/to/file.pyYou should set BDD tag‘@allure.story’ for your test function(s):
Test function: ‘test_case’, location: /path/to/file.py================== no tests ran in 0.00 seconds ===================$ pytest –all-skipped-fail======================= test session starts =======================(hidden for brevity)test_fail_on_all_skipped_when_skip.py::test_case SKIPPED                 [100%]Changed exitcode to FAILED because all tests were skipped.======================== 1 skipped in 0.01s =======================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-markers-presence” is free and open source softwareIssuesIf you encounter any problems, pleasepytest-markers-presencealong with a detailed description.
Package: pytest-markfiltration
The default py.test keyword filtering (-k) is _way_ too broad. You would think that it
would be based on the MarkInfo objects that are described alongside the filter option
but that would be incorrect. In fact, it chooses the method/function name of the script
as well.This plugin introduces a -f flag for pytest that takes the name of a MarkInfo object to
either keep or remove from the collected scripts.The syntax is the same as with -k. So…To include a script with a MarkInfo object on itpy.test -f rhinoAnd to disclude onepy.test -f -hippoJust like with -k you can do an ‘and’ collection as well withpy.test -f “hippo rhino”orpy.test -f “hippo -rhino”But the built-in -k does not let you do an ‘or’ collection. -f does allow for it though through multiple instances of he flagpy.test -f hippo -f rhinoand perhaps a silly example ofpy.test -f hippo -f -rhinoTo install, either
* pip install pytest-markfiltration
* python setup.py install
Package: pytest-mark-no-py3
pytest-mark-no-py3This package provides a pytest plugin and aBowlercodemod to help migrate tests to Python 3.Any tests marked with@pytest.mark.no_py3will be expected to fail when
running on Python 3 and will fail the test if they pass unexpectedly.UsageAdding@pytest.mark.no_py3Install this package in your test dependencies.Run your tests on Python 3, savings the results with pytest's--result-logoption, e.g.:tox-epy37----result-log=test-results.txtInstall this package with thebowlerextras in a Python 3 virtualenv:pipinstallpytest_mark_no_py3[bowler]Apply the marker to all of the tests that failed on Python 3, running from
the same directory that you ran the tests from:python-mpytest_mark_no_py3.add--result-log=path/to/result-log.txtpath/to/your/testsIf you're feeling confident, you can also use the--no-interactiveoption
to apply the codemod without prompting to accept changes.Removing@pytest.mark.no_py3Fix some code so that tests start passing on Python 3, violating the xfail.Run your tests on Python 3, savings the results with pytest's--result-logoption, e.g.:tox-epy37----result-log=test-results.txtWarning:The only failing tests should be the tests that you fixed and
want the marker removed from!Install this package with thebowlerextras in a Python 3 virtualenv:pipinstallpytest_mark_no_py3[bowler]Remove the marker from all of the tests that "failed" (i.e. were expected to
fail but actually passed) on Python 3, running from the same directory that
you ran the tests from:python-mpytest_mark_no_py3.remove--result-log=path/to/result-log.txtpath/to/your/testsIf you're feeling confident, you can also use the--no-interactiveoption
to apply the codemod without prompting to accept changes.Running testsRuntox.
Package: pytest-marks
Pytest-Marks============The ability to set 'marks' on py.test test methods is pretty cool.@pytest.mark.reddef some_test_method(self):# some check-y stuffBut if you have a half dozen marks that you want to put on a method, it gets kinda yucky.@pytest.mark.red@pytest.mark.green@pytest.mark.blue@pytest.mark.black@pytest.mark.orange@pytest.mark.pinkdef some_test_method(self):# some check-y stuffWhat would be nice is if you could apply them all in a single decorator.@pytest.marks('red', 'green', 'blue', 'black', 'orange', 'pink')def some_test_method(self):# some check-y stuffWell, now you can.To install, either* pip install pytest-marks* python setup.py install
Package: pytest-matcher
What is thisThis is apytestplugin that provides a couple of fixtures to match
test output against patterns stored in files.The plugin extends pytest with the following CLI options:--pm-save-patterns– to store the output to a pattern file (instead of checking);--pm-patterns-base-dirto specify a base directory, where to lookup pattern files.Pattern files are stored in a base directory, and additional paths, based on the test
module name, test class name, and test function name, are as follows:<base-dir>/<test-module-name>/[test-class-name/]<test-function-name>[[<callspec-id>]]Note, that for non-class test functions, thetest-class-namepart is absent.
For parametrized tests, thecallspec-idpart containing %XX-escaped information
about the parametrization is added.Quick StartThe plugin providesexpected_outandexpected_errnamed fixture functions.deftest_foo(capfd,expected_out):print('foo')stdout,stderr=capfd.readouterr()assertstdout==expected_outAddpm-patterns-base-diroption topytest.inifile andpytestsection
pointing, for example, totest/data/expected. Thepyproject.tomlexample
can be found in this repository. For the firstpytestrun, it would
fail because there is no expected pattern file present. To write it, one can usepytestCLI:$ pytest --pm-save-patterns test/test_foo.py::test_fooReview the stored pattern file and add it to your VCS.See AlsoHow it works
Package: pytest-match-skip
Skip matching marks. Matches partial marks using wildcards.ThisPytestplugin was generated withCookiecutteralong with@hackebrot’sCookiecutter-pytest-plugintemplate.FeaturesAllows any tag to be used for a skip or xfailWildcards can be used for tags with variable parts (ie: Specify bug_.* for bug_123, bug_777)Important tags can be specified and the user will be warned when they’re skippedTags that should be skipped can be forced to run anywaysInstallationYou can install “pytest-match-skip” viapipfromPyPI:pip install pytest-match-skipUsagecommand line optionsThe following pytest options can be used on the command line:–skip_marks–important_marks–run_skips–xfail_skipspytest ini optionsThe following options can be added to a pytest.ini file:skip_marks: List of marks that will be detectedimportant_marks: List of marks that will warn the user if skippedrun_skips: true or false to run tests with a skip markxfail_skips: true or false to xfail instead of skip the marked testsExample:[pytest]skip_marks=bug_.*.*_tracker.*_known_failure_.*important_marks=smoke.*_sanityimportant_.*run_skips=falsexfail_skips=falseHooksThe following pytest hooks are available:pytest_match_skip_reason(request, message) - Called if a test is skippedpytest_match_skip_run_skip_warning(request, message) - Called if run_skips is true and a test would otherwise be skipped.pytest_match_skip_important_warning(request, message) - Called when important_marks are skippedContributingContributions 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-match-skip” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-maxcov
OverviewTHIS PLUGIN IS IN DEVELOPMENT -- Expect bugs. Expect incomplete behaviourpytest-maxcovis apytestplugin to compute the maximum coverage available through pytest with the minimum execution time cost. The plugin serves two main use cases:to identify redundant unit tests which do not add additional coverageto discover a subset of unit tests which achieves a minimum coverage level, for example to create a fast subset for a smoke testInstallationpython3-mpipinstallpytest-maxcovUsageThe plugin works in two passes:Run alongsidepytest-covto collect coverage information and time every test. Pass--maxcov-recordon the command-line topytestto configure the plugin to capture the data it needs for the second pass. You must also include--cov-context=textto that per-test coverage can be measured.Run using--maxcovto read the data from pass one to mark tests as skipped if they are not needed to achieve the chosen coverage level.The command-line option--maxcov-thresholdspecifies the threshold for computing the minimum set of tests. By default this is 100%.For example using Poetry andpytest-xdist:poetry run pytest -n logical --maxcov-record --cov=mypackage --cov-branch --cov-context=test
poetry run pytest -n logical --maxcov --cov=mypackage --cov-branchLimitationsCurrent limitations include:multiple contexts are not supported; the plugin assumes everything runs in a single contextmultiple coverage files are not supported; the plugin reads from.coverageby default or the data file specified by the environment variableCOVERAGE_FILELicenseAll code in this repository is licensed under theMIT License
Package: pytest-maybe-context
pytest-maybe-contextMakes it a bit easier to write warning and exception checks along other cases.frompytestimportmark,raises,warnsfrompytest_maybe_contextimportmaybe_context,not_context@mark.parametrize(('buffering','expected'),((0,b'contents'),(1,warns(RuntimeWarning)),(.1,raises(TypeError))))deftest_example(buffering,expected):withmaybe_context(expected):file=open('file','rb',buffering)ifnot_context(expected):assertfile.read()==expectedInstallationpoetryaddpytest-maybe-context--groupdev
Package: pytest-maybe-raises
pytest-maybe-raisesPytest fixture for optional exception testing.DocumentationI like to parametrize tests for functions that could accepts different
values. I often find myself writing this type of pattern:importpytest@pytest.mark.parametrize(('value','expected_result'),(('foo','bar'),('baz',ValueError)))deftest_something(value,expected_result):ifhasattr(expected_result,'__traceback__'):# is an exceptionwithpytest.raises(expected_result):my_func(value)else:result=my_func(value)assertresult==expected_resultassertbool(result)But this is really long and ugly.Does pytest provides a fixture that allows me to only uses thepytest.raisescontext when the provided argument is an exception class? The answer is not (seethis question in Stackoverflow),
so I've written this convenient fixture:importcontextlibimportpytest@contextlib.contextmanagerdef_maybe_raises(maybe_exception_class,*args,**kwargs):ifhasattr(maybe_exception_class,'__traceback__'):withpytest.raises(maybe_exception_class,*args,**kwargs)asexc_info:yieldexc_infoelse:yieldmaybe_exception_class@pytest.fixture()defmaybe_raises():return_maybe_raisesThis package provides a wrapper fixture overpytest.raiseswhich
context only has effect if the passed argument is an exception class,
otherwise uses a null context likecontextlib.nullcontext.Using this package I can rewrite my tests as:importpytest@pytest.mark.parametrize(('value','expected_result'),(('foo','bar'),('baz',ValueError)))deftest_something(value,expected_result,maybe_raises):withmaybe_raises(expected_result):result=my_func(value)assertresult==expected_resultassertbool(result)But in order to use it properly you need to know how the magic works:Note that when an exception raises insidepytest.raisescontext, the
context exits so the laterassert ... == expected_resultcomparison
is not executed. If other exception raises would be propagated to your test
so the comparison is not executed either. This allows you to write more
assertions after the execution of the function for successfull calls.
Package: pytest-mccabe
pytest-mccabepytest plugin for checking cyclomatic complexity of python source withmccabe.NOTE:I (@The-Compiler) stopped using this plugin in 2016. While I will still review pull requests and release new versions if needed by the community, I do not have the time to continue maintaining this plugin myself. You might want to consider switching topytest-flake8ortox+flake8instead (see someargumentson why).Usageinstall via:pip install pytest-mccabeif you then type:pytest --mccabeevery file ending in.pywill be discovered and run through mccabe,
starting from the command line arguments.Simple usage exampleConsider you have this (deliberately bad and complex) code:# module.pyimportrandomimportos.pathdefsome_function():num=random.random()if0<=num<0.1:print("1")elif0.1<=num<0.2:print("2")elif0.2<=num<0.3:print("3")elif0.3<=num<0.4:print("4")elif0.4<=num<0.5:print("5")elif0.5<=num<0.6:print("6")elif0.6<=num<0.7:print("7")elif0.7<=num<0.8:print("8")elif0.8<=num<0.9:print("9")elif0.9<=num<1:print("10")Running pytest with pytest-mccabe installed shows you this function is
considered too complex:$ pytest -q --mccabe module.py
F
============================== FAILURES ==============================
____________________________ mccabe-check ____________________________
.../module.py:4: C901 'some_function' is too complex (11)Configuring mccabe complexity per project and fileYou may configure the maximum complexity for your project
by adding anmccabe-complexityentry to pytest config file (e.g.setup.cfg) like this:[pytest]mccabe-complexity=15Rerunning with the above example will now look better:$ pytest -q --mccabe foo.py
.
1 passed in 0.00 secondsIf you have some files where you want to set a higher complexity than the
project-wide one, you can start a mccabe-complexity line with a glob-pattern:[pytest]mccabe-complexity=*.py 7magic.py 10Ignoring certain functionsYou can exclude certain functions from the complexity check by adding comments
like this:defsome_function():# noqa...defanother_function():# pragma: no mccabe...(both will work -# noqais mainly there forflake8compatibility)Running mccabe checks and no other testsYou can restrict your test run to only perform “mccabe” tests
and not any other tests by typing:pytest --mccabe -m mccabeThis will only run tests that are marked with the “mccabe” keyword
which is added for the mccabe test items added by this plugin.If you are using pytest < 2.4, then use the following invocation
to the same effect:pytest --mccabe -k mccabeNotesThe repository of this plugin is athttps://github.com/The-Compiler/pytest-mccabeFor more info on pytest seehttps://pytest.orgThe code is based on Florian Schulze’s excellentpytest-flakes- Thanks!Changes0.1Initial release.1.0Drop support for Python 2.6, 3.2, 3.3 and 3.4Add support for Python 3.5, 3.6 and 3.7Make this plugin compatible with pytest 4.x and 5.xDrop support for “setup.py test”Remove outdated pytest-cache dependencyVarious code/CI cleanups2.0Drop support for Python 2.7Drop support for pytest < 5.4Add support for Python 3.8 (no changes required)Fix deprecation warnings with pytest >= 5.4 (thanks to Martin Thoma for the PR!)Various code/CI cleanups
Package: pytest-md
pytest-mdPlugin for generating Markdown reports forpytestresults 📝Installationpytest-mdis available onPyPIfor Python versions 3.6 and newer
and can be installed into your enviroment from your terminal viapip:$ pip install pytest-mdUsageThe following example code produces all of the different pytest test outcomes.importrandomimportpytestdeftest_failed():assert"emoji"=="hello world"@pytest.mark.xfaildeftest_xfailed():assertrandom.random()==1.0@pytest.mark.xfaildeftest_xpassed():assert0.0<random.random()<1.0@pytest.mark.skip(reason="don't run this test")deftest_skipped():assert"pytest-emoji"!=""@pytest.mark.parametrize("name, expected",[("Sara","Hello Sara!"),("Mat","Hello Mat!"),("Annie","Hello Annie!"),],)deftest_passed(name,expected):assertf"Hello{name}!"==expected@pytest.fixturedefnumber():return1234/0deftest_error(number):assertnumber==numberWithpytest-mdinstalled, you can now generate a Markdown test report as
follows:$ pytest --md report.md# Test Report*Report generated on 25-Feb-2019 at 17:18:29 by [pytest-md]*[pytest-md]:https://github.com/hackebrot/pytest-md## Summary8 tests ran in 0.05 seconds-1 failed-3 passed-1 skipped-1 xfailed-1 xpassed-1 errorpytest-emojipytest-mdalso integrates withpytest-emoji, which allows us to include
emojis in the generated Markdown test report:$ pytest --emoji -v --md report.md# Test Report*Report generated on 25-Feb-2019 at 17:18:29 by [pytest-md]*📝

[pytest-md]:https://github.com/hackebrot/pytest-md## Summary8 tests ran in 0.06 seconds ⏱-1 failed 😰-3 passed 😃-1 skipped 🙄-1 xfailed 😞-1 xpassed 😲-1 error 😡CreditsThis project is inspired by the fantasticpytest-htmlplugin! 💻CommunityWould you like to contribute topytest-md? You're awesome! 😃Please check out thegood first issuelabel for tasks, that
are good candidates for your first contribution topytest-md. Your
contributions are greatly appreciated! Every little bit helps, and credit will
always be given! Find out who has already contributed topytest-mdhere!  🌍🌏🌎Please note thatpytest-mdis released with aContributor Code of
Conduct. By participating in this project you agree to abide
by its terms.LicenseDistributed under the terms of the MIT license,pytest-mdis free and open
source software.