Saravanan666/pypi-org huggingface dataset:
Package: pytest-tmp-files
pytest_tmp_filesis a pytest plugin that provides a fixture for creating
temporary file hierarchies.  This fixture is calledtmp_files, and you can
think of it as an extension of the built-intmp_pathfixture.  In addition
to creating a unique temporary directory for each test,tmp_filesalso
fills in that directory with any files needed for that test.The files to create are specified by a dictionary provided to fixture viaindirect parametrization.  For example, here’s a test for a function that
searches for files whose contents match a given regular expression:importpytest,refrompathlibimportPathdeffind_text(top,pattern):hits=set()forpathinPath(top).glob('**/*'):ifpath.is_file()andre.search(pattern,path.read_text()):hits.add(path)returnhits@pytest.mark.parametrize('tmp_files, pattern, expected',[({'a':'x'},'x',{'a'}),({'a':'x'},'y',set()),({'a/b':'x'},'x',{'a/b'}),({'a/b':'x'},'y',set()),({'a/b':'x','c':'y'},'x',{'a/b'}),({'a/b':'x','c':'y'},'y',{'c'}),({'a/b':'x','c':'y'},'[xy]',{'a/b','c'}),],indirect=['tmp_files'],)deftest_find_text(tmp_files,pattern,expected):expected={tmp_files/pforpinexpected}assertfind_text(tmp_files,pattern)==expectedThe first parameter in each set (the dictionary) specifies the files to create.
The keys are file paths and the values are file contents, so{'a/b': 'x'}specifies a subdirectoryacontaining a text filebwith the contentsx.  Although not shown here, it’s also possible to create different kinds
of files (e.g. binary files, symlinks, hard links, named FIFOs) and to specify
file metadata (e.g. permissions, modification times).If this plugin sounds useful to you, you may also be interested inParametrize
From File.  These two packages work really well together, becausetmp_fileslends itself to long, multi-line parameters andParametrize From
Filemakes such parameters easier to manage.Check out thedocumentationfor more information.
Package: pytest-tmpfs
pytest-tmpfsA pytest plugin that helps you on using a temporary filesystem for testingimportjsondefreadjson(path:str)->dict:"""Example:>>> path = fs.write('a/b/c.json', '{"a": 2}')>>> readjson(path){'a': 2}"""withopen(path,'r')asf:returnjson.load(f)This plugin is a fake filesystem manager implementation that relies on thepytest'stmp_pathfixture to enable safe testing of projects that require disk operations and are difficult to mock.Alternativespyfakefs: good alternative if you wish to mock filesystem operations.tempfile: creates files and directories temporarily.InstallFor installing this package, just type the command below in your terminal:pip install pytest-tmpfsUsageAs a fixtureYou can use theTmpFsas a fixture by passingtmpfsas an argument of your test function.importpytest_tmpfsdeftest_readjson(tmpfs:pytest_tmpfs.TmpFs):path=tmpfs.write('a/b/d.json','{"a": 2}')assertreadjson(path)=={'a':2}In doctestsBy installing this plugin, all doctests are automatically enabled to usefs, a variable that stores an instance ofTmpFs.deffscheck(path:str)->dict:"""Example:>>> fs.touch('a/b/c.txt')>>> fs.ls('a/b')['c.txt']"""passYour own instanceIf you seek to use this plugin without pointing totmp_pathit is possible to create your own instance and to manipulate it the way you want.importpytest_tmpfsdeftest_random():mypath=pathlib.Path('a/b/c')fs=TmpFs(mypath)FeaturesThe following table contains all methods thatTmpFsimplements and its descriptions:MethodDescriptionExampleParametersReturnwritewrites a file in the disk and adds line by line content to itfs.write('a/b.txt', 'Hello', 'World!')path, *linesabs path to the filereadreads the contents of a file and returns it as a stringfs.read('a/b.txt')pathabs path to the filelslists all files inside a folderfs.ls('a')pathsorted list of folders and filesrmremoves a file or a folderfs.rm('a')pathTrue if succeded, False if notmkdircreates one or more foldersfs.mkdir('b/c')pathabs path to the foldermvmoves a file or a folder to another pathfs.mv('a/b.txt', 'b/c')path, pathabs path to destinationcleanremoves all files inside the root of the tmp fsfs.clean()pathconverts a relative path into an abs pathfs.path('a')pathabs path to the file or foldertreeprints a tree-like structure of a folderfs.tree('a')pathtree_formatsame as tree, but outputs a stringfs.tree_format('a')pathtree representationcatprints the content of a filefs.cat('b/c/b.txt')pathtouchcreates an empty filefs.touch('a/c.txt')pathabs path to the filetmp_cwdchanges CWD to the temporary filesystem folderfs.tmp_cwd()abs path to the fs rootcwdreturns to the original CWDfs.cwd()abs path to the old cwdNote:tmp_cwdandcwdcan be used withwith statements.ContributingFeel free to contribute to this project, just remember to use pre-commit and to write unit tests for new features/bugs.
Package: pytest-tmux
pytest-tmuxA pytest plugin that enables tmux driven testsThis plugin is intend to help users who want to test interrative cli.When usingtmuxfixture it basically :creates a tmux server (socket created in pytest tmpdir)creates a session automaticallyattach to the window automaticallyattach to the pane automaticallyWarningsUntil a stable release, it is greatly encouraged to specify a strict version if
you use this tool in your CI since it is in its early development and could be
greatly changed between version.Docshttps://pytest-tmux.readthedocs.io/FeaturesEnable tmux driven testsEnable screen assertion with retryEnable row assertion with retryAllow to debug tests interactivelyRequirementspython >= 3.7pytesttmuxInstallationYou can install "pytest-tmux" viapipfromPyPI:$ pip install pytest-tmuxConfiguration capabilitiesConfiguration could be set on different level (in order of precedence):Serverby overriding tmux_server_config (scope='session') fixtureenv varcli args (see --tmux-* switch with pytest --help)Sessionby overriding tmux_session_config fixtureat the test level with tmux_session_cfg markerdynamically inside test withtmux.config.sessionenv varcli args (see --tmux-* switch with pytest --help)Assertionby overriding tmux_assertion_config fixtureat the test level with tmux_assertion_cfg markerdynamically inside test withtmux.config.sessionwhen callingtmux.screen() / tmux.row()withtimeout/delayargumentenv varcli args (see --tmux-* switch with pytest --help)UsageBasic exampleimportpytestfrominspectimportcleandocdeftest_assert(tmux):# Set some options before session / windows is startedtmux.config.session.window_command='env -i PS1="$ " TERM="xterm-256color" /usr/bin/env bash --norc --noprofile'asserttmux.screen()=='$'tmux.send_keys(r'printf "  Hello World  .\n\n"')expected=r"""$ printf "  Hello World  .\n\n"Hello World  .$"""asserttmux.screen()==cleandoc(expected)LicenseDistributed under the terms of theMITlicense, "pytest-tmux" is free
and open source softwareIssuesIf you encounter any problems, pleasefile an
issuealong with a
detailed description.
Package: pytest-todo
Marking unfinished source code or known problems with aTODOcomment is a
popular method among developers. During development this is an acceptable,
lightweight option. In a release version howeverTODOcomments leave a bitter
taste at best or mean a forgotten major issue at worst.This plugin parses Python source files forTODOcomments and marks them as a
failed test.Usage~$pytest--todoPossible UsageDuring development the CI server simply runs the unit tests against the code,
checking if the tests pass. At this stageTODOcomments are allowed. Once a
release candidate exists (maybe on a release branch) the CI server will also
add the–todoflag. ForgottenTODOcomments will now cause the tests to
fail and a possible source of bugs is cleared out before the release happens.
Package: pytest-tomato
🍅 pytest-tomato===============pytest plugin for `tomato-bot <https://tomato-bot/>`__Installation------------``pip install pytest-tomato``Usage-----Nada, after installing pytest will publish test results to thetomato-bot 🍅Setting junit-xml path----------------------In order to parse test results the tomato bot read junit xml filescreated by pytest junit plugin. By default pytest doesn’t generates thisfile so ``pytest-tomato`` enables junit xml generation. If you wantcontrol the path of the xml pass ``--junit-xml=<location>.xml`` flag topytest.
Package: pytest-toolbelt
[![Build Status](https://travis-ci.org/adalekin/pytest-toolbelt.svg?branch=master)](https://travis-ci.org/adalekin/pytest-toolbelt) [![Coverage Status](https://coveralls.io/repos/github/adalekin/pytest-toolbelt/badge.svg?branch=master)](https://coveralls.io/github/adalekin/pytest-toolbelt?branch=master)PyTest ToolbeltThis is just a collection of utilities for pytest, but don’t really belong in pytest proper.Installation` pip installpytest-toolbelt`TestsTo run the test suite execute the following command in package root folder:` python setup.py test `
Package: pytest-toolbox
Copyright (C) 2016 Samuel ColvinNumerous useful plugins for pytest.FixturestmpworkdirRun the test with the working directory set to a temporary directory. Similar to the pytest plugintmpdirexcept working directory is changed.smart_caplogcapture logs with a smarter interface than pytest’s nativecaplogprint_logsprint all logs.loopasyncio loop.Methods(See below for usage examples).mktreeCreate a tree of files from a dictionary.gettreeReturn a dictionary depicting a directory tree.Comparison ObjectsAll can be imported frompytest_toolbox.comparison.CloseToNowcheck that a date (or date-like object) is close to nowAnyIntcheck tests that an object is an intRegexStrcheck that a string matches the regexIsUUIDthat that an object is an instance ofUUID.Used with equals as inmy_date == CloseToNow(), these are useful when checking objects which contain
a few unknown values are as expectedEg.assert{'details':{'user':'foobar@example.com','id':AnyInt(),'published':False,'event':'an example','created_ts':CloseToNow(),},'other_thing':[...],...}==objUsagefrompytest_toolboximportgettree,mktreedeftest_whatever(tmpworkdir):mktree(tmpworkdir,{'foobar.txt':'has this content'})assertgettree(tmpworkdir)={'foobar.txt':'has this content'}TODO
Package: pytest-tornado
Apy.testplugin providing fixtures and markers to simplify testing
of asynchronous tornado applications.Installationpip install pytest-tornadoExampleimportpytestimporttornado.webclassMainHandler(tornado.web.RequestHandler):defget(self):self.write("Hello, world")application=tornado.web.Application([(r"/",MainHandler),])@pytest.fixturedefapp():returnapplication@pytest.mark.gen_testdeftest_hello_world(http_client,base_url):response=yieldhttp_client.fetch(base_url)assertresponse.code==200Running testspy.testFixturesio_loopcreates an instance of thetornado.ioloop.IOLoopfor each test casehttp_portget a port used by the test serverbase_urlGet an absolute base url for the test server,
for examplehttp://localhost:59828.
Can also be used in a test with HTTPS fixture and will then return
a corresponding url, for examplehttp://localhost:48372.http_serverstart a tornado HTTP server, you must create anappfixture,
which returns thetornado.web.Applicationto be testedhttp_clientget an asynchronous HTTP clientThere is also the possibility to test applications with HTTPS.
For running a server with HTTPS you need a certificate.https_portGet a port used by the test server.https_serverStart a tornado HTTPS server. You must create anappfixture,
which returns thetornado.web.Applicationto be tested, and
anssl_optionsfixture which returns the SSL options for thetornado.httpserver.HTTPServer.https_clientGet an asynchronous HTTP client.
In case your test uses an self-signed certificate you can setverify=Falseon the fetch method.Show fixtures provided by the plugin:py.test --fixturesMarkersAgen_testmarker lets you write a coroutine-style tests used with thetornado.genmodule:@pytest.mark.gen_testdeftest_tornado(http_client):response=yieldhttp_client.fetch('http://www.tornadoweb.org/')assertresponse.code==200This marker supports writing tests with async/await syntax as well:@pytest.mark.gen_testasyncdeftest_tornado(http_client):response=awaithttp_client.fetch('http://www.tornadoweb.org/')assertresponse.code==200Marked tests will time out after 5 seconds. The timeout can be modified by
setting anASYNC_TEST_TIMEOUTenvironment variable,--async-test-timeoutcommand line argument or a marker argument.@pytest.mark.gen_test(timeout=5)deftest_tornado(http_client):yieldhttp_client.fetch('http://www.tornadoweb.org/')The mark can also receive a run_sync flag, which if turned off will, instead of running the test synchronously, will add it as a coroutine and run the IOLoop (until the timeout). For instance, this allows to test things on both a client and a server at the same time.@pytest.mark.gen_test(run_sync=False)deftest_tornado(http_server,http_client):response=yieldhttp_client.fetch('http://localhost:5555/my_local_server_test/')assertresponse.body=='Run on the same IOLoop!'Show markers provided by the plugin:py.test --markers
Package: pytest-tornado5
Apy.testplugin providing fixtures and markers to simplify testing
of asynchronous tornado applications.Installationpip install pytest-tornadoExampleimportpytestimporttornado.webclassMainHandler(tornado.web.RequestHandler):defget(self):self.write("Hello, world")application=tornado.web.Application([(r"/",MainHandler),])@pytest.fixturedefapp():returnapplication@pytest.mark.gen_testdeftest_hello_world(http_client,base_url):response=yieldhttp_client.fetch(base_url)assertresponse.code==200Running testspy.testFixturesio_loopcreates an instance of thetornado.ioloop.IOLoopfor each test casehttp_portget a port used by the test serverbase_urlget an absolute base url for the test server,
for example,http://localhost:59828http_serverstart a tornado HTTP server, you must create anappfixture,
which returns thetornado.web.Applicationto be testedhttp_clientget an asynchronous HTTP clientShow fixtures provided by the plugin:py.test --fixturesMarkersAgen_testmarker lets you write a coroutine-style tests used with thetornado.genmodule:@pytest.mark.gen_testdeftest_tornado(http_client):response=yieldhttp_client.fetch('http://www.tornadoweb.org/')assertresponse.code==200Marked tests will time out after 5 seconds. The timeout can be modified by
setting anASYNC_TEST_TIMEOUTenvironment variable,--async-test-timeoutcommand line argument or a marker argument.@pytest.mark.gen_test(timeout=5)deftest_tornado(http_client):yieldhttp_client.fetch('http://www.tornadoweb.org/')The mark can also receive a run_sync flag, which if turned off will, instead of running the test synchronously, will add it as a coroutine and run the IOLoop (until the timeout). For instance, this allows to test things on both a client and a server at the same time.@pytest.mark.gen_test(run_sync=False)deftest_tornado(http_server,http_client):response=yieldhttp_client.fetch('http://localhost:5555/my_local_server_test/')assertresponse.body=='Run on the same IOLoop!'Show markers provided by the plugin:py.test --markers
Package: pytest-tornado-yen3
Apy.testplugin providing fixtures and markers to simplify testing
of asynchronous tornado applications.Installationpip install pytest-tornadoExampleimportpytestimporttornado.webclassMainHandler(tornado.web.RequestHandler):defget(self):self.write("Hello, world")application=tornado.web.Application([(r"/",MainHandler),])@pytest.fixturedefapp():returnapplication@pytest.mark.gen_testdeftest_hello_world(http_client,base_url):response=yieldhttp_client.fetch(base_url)assertresponse.code==200Running testspy.testFixturesio_loopcreates an instance of thetornado.ioloop.IOLoopfor each test casehttp_portget a port used by the test serverbase_urlget an absolute base url for the test server,
for example,http://localhost:59828http_serverstart a tornado HTTP server, you must create anappfixture,
which returns thetornado.web.Applicationto be testedhttp_clientget an asynchronous HTTP clientShow fixtures provided by the plugin:py.test --fixturesMarkersAgen_testmarker lets you write a coroutine-style tests used with thetornado.genmodule:@pytest.mark.gen_testdeftest_tornado(http_client):response=yieldhttp_client.fetch('http://www.tornadoweb.org/')assertresponse.code==200Marked tests will time out after 5 seconds. The timeout can be modified by
setting anASYNC_TEST_TIMEOUTenvironment variable,--async-test-timeoutcommand line argument or a marker argument.@pytest.mark.gen_test(timeout=5)deftest_tornado(http_client):yieldhttp_client.fetch('http://www.tornadoweb.org/')The mark can also receive a run_sync flag, which if turned off will, instead of running the test synchronously, will add it as a coroutine and run the IOLoop (until the timeout). For instance, this allows to test things on both a client and a server at the same time.@pytest.mark.gen_test(run_sync=False)deftest_tornado(http_server,http_client):response=yieldhttp_client.fetch('http://localhost:5555/my_local_server_test/')assertresponse.body=='Run on the same IOLoop!'Show markers provided by the plugin:py.test --markers
Package: pytest-tornasync
A simple pytest plugin that provides some helpful fixtures for testing
Tornado (version 5.0 or newer)  apps and easy handling of plain
(undecoratored) native coroutine tests (Python 3.5+).Why another Tornado pytest plugin when the excellentpytest-tornadoalready
exists? The main reason is that I didn’t want to have to decorate every test
coroutine with@pytest.mark.gen_test. This plugin doesn’t have anything
likegen_test. Defining a test withasync defand a name that
begins withtest_is all that is required.InstallationInstall using pip, which must be run with Python 3.5+:pipinstallpytest-tornasyncUsageDefine anappfixture:importpytest@pytest.fixturedefapp():importyourappreturnyourapp.make_app()# a tornado.web.ApplicationCreate tests as native coroutines using Python 3.5+async def:asyncdeftest_app(http_server_client):resp=awaithttp_server_client.fetch('/')assertresp.code==200# ...FixturesWhen the plugin is installed, thenpytest--fixtureswill show
the fixtures that are available:http_server_portPort used byhttp_server.http_serverStart a tornado HTTP server that listens on all available interfaces.You must create anappfixture, which returns
thetornado.web.Applicationto be tested.Raises:
FixtureLookupError: tornado application fixture not foundhttp_server_clientCreate an asynchronous HTTP client that can fetch fromhttp_server.http_clientCreate an asynchronous HTTP client that can fetch from anywhere.io_loopCreate a newtornado.ioloop.IOLoopfor each test case.Examplesimporttimeimporttornado.webimporttornado.genimportpytestclassMainHandler(tornado.web.RequestHandler):defget(self):self.write("Hello, world!")@pytest.fixturedefapp():returntornado.web.Application([(r"/",MainHandler)])asyncdeftest_http_server_client(http_server_client):# http_server_client fetches from the `app` fixture and takes pathresp=awaithttp_server_client.fetch('/')assertresp.code==200assertresp.body==b"Hello, world!"asyncdeftest_http_client(http_client):# http_client fetches from anywhere and takes full URLresp=awaithttp_client.fetch('http://httpbin.org/status/204')assertresp.code==204asyncdefexample_coroutine(period):awaittornado.gen.sleep(period)asyncdeftest_example():# no fixtures neededperiod=1.0start=time.time()awaitexample_coroutine(period)elapsed=time.time()-startassertelapsed>=periodChanges0.6.0 (2018-11-19)minor updates to avoid a pytest warning under pytest 4repo switch to using a ‘src’ dir0.5.0 (2018-05-28)updated to work with Tornado 5, which is now the minimum required versionrequire pytest >= 3.0theio_loopfixture always refers to atornado.ioloop.IOLoop instancenowtheio_loop_asyncioandio_loop_tornadofixtures have been removed, since
now that Tornado 5 always uses asyncio under Python 3, there would be no
difference between the two fixtures, soio_loopis all that is neededtox tests now test more versions of Tornado (5.0.* and latest 5.*),
Pytest (3.0.* and latest 3.*), and Python (3.5, 3.6, 3.7, and pypy3).
Package: pytest-track
Pytest plugin for additional test reportingOffers additional 2 reporting options:Skipped tests percentage(For Selenium tests) HTML Coverage reportThese two functionalities are not related and can be used separately. At the time, it's just easier to have them
in the same codebase.
Both of them have the option to output the report in terminal or Confluence.Skipped test percentageTo execute it:$ pytest demo --track terminal
============== test session starts ===================
plugins: track-0.1.0
collected 7 items

demo/test_models.py .s.s.                       [ 71%]
demo/test_views.py .s                           [100%]

======= 4 passed, 3 skipped in 0.02 seconds ==========
Total: 4 from 7 tests not skipped (57.14%)
    test_models, 3 from 5 tests not skipped (60.00%)
    test_views, 1 from 2 tests not skipped (50.00%)Current functionality requires only test collection so this can be used with pytest's--collect-onlyTo store result in Confluence, see the Confluence Configuration section and use:$ pytest --track confluenceHTML CoverageTo have this you need both to have selenium tests and access to the HTML source for the project
you want to compute coverage.This plugin works by recording all the identifiable source code elements in the HTML source and comparing
how many of them the selenium tests view and inspect.In greater details this is doing:In the plugin configure phase, read HTML files and create a simple tree with identifiable elementsThis step can be cached (See options)Identifiable elements is a tag with an id or a class or aa special HTML tag (app- for Angular)While tests run, on each Selenium driver URLget, record the received HTML as viewedWhile tests run, on each Selenium driverfind_element, record the element as inspectedIn the  plugin unconfigure phase, calculate a naive % HTML seen and % HTML inspected$ pytest --html-cov terminal --html-cov-dir=<directory_with_HTML_source>To cache HTML source parse set, use$ pytest --html-cov --html-cov-cacheTo also report missing elements, use$ pytest --html-cov --html-cov-show-elementsTo store result in Confluence, see the Confluence Configuration section and use:$ pytest --html-cov confluenceConfluence reportingTo configure Confluence settings add a section to pytest.ini[pytest_track]
track_confluence_username=<confluence_username>
track_confluence_password=<confluence_password>
track_confluence_url=<confluence_root_url>
# For skipped test percentage
confluence_report_parent_page_id=<id_of_the_parent_page>
confluence_report_page_title=<title_for_the_results_page>
# For HTML coverage
confluence_coverage_parent_page_id=<id_of_the_parent_page>
confluence_coverage_page_title=<title_for_the_results_page>ContribBefore PRs, only:pre-commit install
toxAcknowledgementsBased on the initial work of Vasilica Dumbrava.
Package: pytest-translations
PyTest TranslationsA py.test plugin to checkgettextpo&mofiles.Test check for:Spelling (using enchant & aspell)Consistency ofmofilesObsolete translationsFuzzy translationsInstallationInstall the PyPi package.pipinstallpytest-translationsThe spell checking requires enchant and aspell including the correct
dictionary.On Linux simply install:sudoapt-getinstallpython3-enchantpython-enchantaspell-{en|de|CHOSEYOURLANGUAGECODES}To set up travis-ci simply add the apt packages to your travis-ci config
YAML:addons:apt:packages:-python-enchant-python3-enchant-aspell-en-aspell-deOn Mac you can use brew to install:brewinstallaspellbrewinstallenchantUsageTo execute the translation tests simply runpy.test--translationsEvery file ending in.moand.powill be discovered and tested,
starting from the command line arguments.You also can execute only the translation-tests by using:py.test-mtranslations--translationsPrivate Word ListsYou will almost certainly use words that are not included in the default
dictionaries. That is why you can add your own word list that you want
to add to the dictionary.You may do so by adding a plain text file where each line is a word.
Words beginning with a capital letter are case sensitive where lower case words
are insensitive.There can be one file for each language contained in a single folder.
The files should be named like the proper language code.For example:.└──.spelling├──de├──en_GB└──en_USWhat’s left to do is to set an environment variable to point to right
directory.For example:exportPYTEST_TRANSLATIONS_PRIVATE_WORD_LIST=path/to/my/.spelling