Saravanan666/pypi-org huggingface dataset:
Package: pytest-dbt-postgres
PyTest DBT PostgresThis project aims to provide an easy way to validate a DBT project by enabling the
unit-testing capability.DependenciesThis project is based on thepytest-postgresqllibrary, so we can
validate our DBT postgres project without relying on an existing database.UsageThe initial idea resides on pytest-postgres providing us an empty and isolated postgres where we can
validate different use-cases with our DBT code.If your project uses external sources, you will need to make sure they are properly defined in the yml files, since
the project generates the DDLs from there.importunittestfrompytest_dbt_postgresimportauto_inject_fixturesfrompytest_dbt_postgres.dbt_executorimportDbtExecutorfrompytest_dbt_postgres.dbt_validatorimportDbtValidatorfrompytest_dbt_postgres.postgres.connectorimportPostgresConnectorfrompytest_dbt_postgres.postgres.sql_methodsimportexport_credentials_to_env,get_credentialsdbt_project_dir='...'resources_folder='...'@auto_inject_fixtures("postgresql")classTestDbtValidator(unittest.TestCase):defsetUp(self)->None:credentials=get_credentials(self.postgresql)self.connector=PostgresConnector(credentials)# SETUPexport_credentials_to_env(credentials)executor=DbtExecutor(dbt_project_dir=dbt_project_dir,profiles_dir=resources_folder)self.validator=DbtValidator(connector=self.connector,executor=executor,resources_folder=resources_folder)deftest_orders(self)->None:# GIVENsources_to_load=[("external.customers","csv/input/customers.csv"),("external.orders","csv/input/orders.csv"),]selector="orders"outputs_to_validate=[("dbt_unittest.orders","csv/output/orders.csv"),]# THENself.validator.validate(sources_to_load,selector,outputs_to_validate)
Package: pytest-dbus-notification
A py.test plugin that displays test results usingD-BUS notifications.This plugins requires thedbusmodule.Using in virtualenvAs of 14 feb 2014,you cannot install python-dbus with pip/easy_install.You have two options:install python-dbus in your virtualenv by downloading and building itinstall python-dbus using your system package (likeapt-get install python-dbus).In the latter case if your virtualenv does not use system packages (that’s the default option), your virtualenv sitll hasn’tdbusmodule available. Just copy it from system packages:# From virtualenv root folder$cp/usr/lib/pyshared/python2.7/_dbus_bindings.solib/python2.7/site-packages/$cp-rcp-r/usr/share/pyshared/dbuslib/python2.7/site-packages/dbus$pythonPython2.7.5+(default,Sep192013,13:48:49)[GCC4.8.1]onlinux2Type"help","copyright","credits"or"license"formoreinformation.>>>importdbus>>>Changelog1.0.1 (2014-03-05)Fixed packaging1.0.0 (2014-02-14)initial release
Package: pytest-dbx
pytest-dbxPytest plugin for testingdbx-based projects.InstallTo use the fixtures in your project, simply addpytest-dbxto your project's dev-dependencies
(where you would place all your test and build dependencies).FixturesIn unit tests you can use thedbx_sparkfixture to have a spark session available as in Databricksdeftest_function(dbx_spark):sdf=dbx_spark.createDataFrame([[1],[2],[3]],['a'])assertsdf.count()==3Thedbutils_fixtureandmlflow_localare automatically used.
Package: pytest-deadfixtures
A simple plugin to list unused or duplicated fixtures in a pytest suite.FeaturesList unused fixtures in your testsList duplicated fixturesInstallationYou can install “pytest-deadfixtures” viapipfromPyPI:$ pip install pytest-deadfixturesUsageImportantThe–dead-fixturesoption 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. For example:script:
  - pytest
  - pytest --dead-fixturesListing unused fixturesJust run ‘pytest’ with an extra option ‘–dead-fixtures’:$ pytest --dead-fixtures
============================= test session starts ==============================
(hidden for brevity)

Hey there, I believe the following fixture(s) are not being used:
Fixture name: some_fixture, location: test_write_docs_when_verbose.py:5

========================= no tests ran in 0.00 seconds =========================Using some level of verbosity will also print the docstring of each fixture:$ pytest --dead-fixtures -v
============================= test session starts ==============================
(hidden for brevity)

Hey there, I believe the following fixture(s) are not being used:
Fixture name: some_fixture, location: test_write_docs_when_verbose.py:5
    Blabla fixture docs

========================= no tests ran in 0.00 seconds =========================Listing repeated fixturesNow that you removed every unused fixture of your test suite, what if you want to go an extra mile?An important note about this is that it uses the fixture return value to verify if two or more fixtures are equal.This meansfixtures without a truthy return value will be skipped.You should use this as a hint only, verify that the functionality provided by both fixtures are really repeated before deleting one of them.Just run ‘pytest’ with an extra option ‘–dup-fixtures’, unlike the ‘–dead-fixtures’ option, it’ll normally run you tests:$ pytest --dup-fixtures
======================================================================================================================== test session starts ========================================================================================================================
(hidden for brevity)

tests/test_deadfixtures.py ........

You may have some duplicate fixtures:
Fixture name: someclass_fixture, location: test_repeated_fixtures.py:12
Fixture name: someclass_samefixture, location: test_repeated_fixtures.py:17Projects using itwemake-django-templateContributingContributions 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-deadfixtures’ is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-deduplicate
pytest_deduplicateThe pytest_deduplicate is designed to identify duplicate or superseeding unit tests that have the same or bigger code coverage.
It can be particularly useful when unit tests are automatically generated based on input/output information for a function,
using a large amount of available input data (for example, with the help of the auger library).This tool groups each test together based on the coverage set.
By invoking unit testing with this tool, it will collect code coverage for each test and generate a list of duplicate tests.
However, it is important to note that false-positives may occur if, for example, there are regular expressions involved, as the code coverage in such cases may appear the same.To use simply call:cd <working_directory>
pytest_deduplicate [pytest_parameters]Result example:def function(x):
    if x % 2 == 0:
        for i in range(1, 3):
            print("even")
        return True
    else:
        print("odd")
        return False


    def test_even0(self):
        self.assertEqual(function(0), True)

    def test_even2(self):
        self.assertEqual(function(2), True)

    def test_odd(self):
        self.assertEqual(function(3), False)

    def test_evenodd(self):
        self.assertEqual(function(2), True)
        self.assertEqual(function(3), False)


Superseeded:
tests/test_simple.py:25:1: I002 test TestSimple.test_evenodd covers more code when test(s) below (bigger-coverage)
tests/test_simple.py:16:1: W003 test TestSimple.test_even0 covers less code when TestSimple.test_evenodd test (smaller-coverage)
tests/test_simple.py:19:1: W003 test TestSimple.test_even2 covers less code when TestSimple.test_evenodd test (smaller-coverage)
tests/test_simple.py:22:1: W003 test TestSimple.test_odd covers less code when TestSimple.test_evenodd test (smaller-coverage)


Duplicates:
tests/test_simple.py:16:1: W001 tests with same coverage: TestSimple.test_even0 (duplicate-test)
tests/test_simple.py:19:1: W001 tests with same coverage: TestSimple.test_even2 (duplicate-test)
Package: pytest-dependency
pytest-dependency – Manage dependencies of testsThis module is a plugin for the popular Python testing frameworkpytest.  It manages dependencies of tests: you may mark some tests
as dependent from other tests.  These tests will then be skipped if
any of the dependencies did fail or has been skipped.DocumentationSee theonline documentation.The example test modules used in the documentation can be found in
doc/examples in the source distribution.Copyright and LicenseCopyright 2013–2015
Helmholtz-Zentrum Berlin für Materialien und Energie GmbHCopyright 2016–2023 Rolf KrahlLicensed under theApache License, Version 2.0 (the “License”); you
may not use this file except in compliance with the License.Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.  See the License for the specific language governing
permissions and limitations under the License.
Package: pytest-deprecate
pytest-deprecateMark tests as testing a deprecated feature with a warning note.Installationpip install pytest-deprecateUsage@pytest.mark.deprecated("This feature will be dropped in 2.7")deftest_old_feature():assertTrueOutput:=========================================================================================================================== warnings summary ============================================================================================================================
example/test_file.py::test_dummy
  /Users/mikailkocak/Development/pytest-deprecate/example/test_file.py:4: UserWarning: test_file:test_dummy is testing a deprecated feature: This feature will be removing in 2.7
    @pytest.mark.deprecated("This feature will be removing in 2.7")
Package: pytest-describe-it
pytest-describe-itExampleSome simple test:importpytestdefadd(x:int,y:int)->int:returnx+y@pytest.mark.describe('add')classTestAdd:@pytest.mark.parametrize(['x','y','expected'],[(1,2,3),(3,4,7),(5,6,10),])@pytest.mark.it('returns{expected}for add({x},{y})')deftest_add(self,x,y,expected):assertadd(x,y)==expectedPytest output:collected3itemstest_add.py..F[100%]======================================FAILURES=======================================________________TestAdd.test_add[[add—returns10foradd(5,6)]]_________________self=<test_add.TestAddobjectat0x10b740b70>,x=5,y=6,expected=10@pytest.mark.parametrize(['x','y','expected'],[(1,2,3),(3,4,7),(5,6,10),])@pytest.mark.it('returns{expected}for add({x},{y})')deftest_add(self,x,y,expected):>assertadd(x,y)==expectedEassert11==10E+where11=add(5,6)test_add.py:18:AssertionError=========================1failed,2passedin0.05seconds==========================With pytest-sugar:collecting...test_add.py✓✓67%██████▋――――――――――――――――TestAdd.test_add[[add—returns10foradd(5,6)]]―――――――――――――――――self=<test_add.TestAddobjectat0x10e4e3550>,x=5,y=6,expected=10@pytest.mark.parametrize(['x','y','expected'],[(1,2,3),(3,4,7),(5,6,10),])@pytest.mark.it('returns{expected}for add({x},{y})')deftest_add(self,x,y,expected):>assertadd(x,y)==expectedEassert11==10E+where11=add(5,6)test_add.py:18:AssertionErrortest_add.py⨯100%██████████Results(0.10s):2passed1failed-test_add.py:11TestAdd.test_add[[add—returns10foradd(5,6)]]
Package: pytest-dictsdiff
pytest-dictsdiffInstallation$ pip install pytest-dictsdiffUsageAt your test usedicts_are_samefixture and use it to compare two
objects:deftest_dicts(dicts_are_same):dict1={'a':1,'b':2,'c':{'d':4,'e':5}}dict2={'a':100,'f':2,'c':{'d':400,'g':5}}assertdicts_are_same(dict1,dict2)Or compare objects using direct function call:frompytest_dictsdiffimportcheck_objectsdeftest_dicts():dict1={'a':1,'b':2,'c':{'d':4,'e':5}}dict2={'a':100,'f':2,'c':{'d':400,'g':5}}assertcheck_objects(dict1,dict2)TodosUsepprintinstead ofjsonwhen showing objects (currently it would fail
if data would contain any non-json-serializable objects)ExampleSave following snippet asdicts.pyand runpytest dicts.py.fromcollectionsimportOrderedDictRESULT=OrderedDict({"cell":"(056)-022-8631","dob":{"age":44,"date":"1983-11-04T01:21:14Z"},"email":"zeyneb.elfring@example.com","gender":"female","id":{"name":"BSN","value":"36180866"},"location":{"city":"tholen","coordinates":{"latitude":"46.8823","longitude":"175.8856"},"postcode":64504,"state":"groningen","street":"2074 adriaen van ostadelaan","timezone":{"description":"Adelaide, Darwin","offset":"+9:30"}},"login":{"md5":"bafe8cf9d37806a7b13edc218d5ff762","password":"ontario","salt":"QVBKgEjy","sha1":"cacef09ff61072d1c55732963766fa84e919aa7a","sha256":"cc86af47aedbdbb1de73ff10484996fe9785c47c0fc191b7c67eaf71e0782300","username":"smallgorilla897","uuid":"37e30c59-bc79-4172-aac6-e2c640e165fa"},"name":{"first":"zeyneb","last":"elfring","title":"mrs"},"nat":"NL","phone":"(209)-143-9697","picture":{"large":"https://randomuser.me/api/portraits/women/37.jpg","medium":"https://randomuser.me/api/portraits/med/women/37.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/women/37.jpg"},"registered":{"age":3,"date":"2014-12-07T06:54:14Z"}})EXPECTED_DATA={"cell":"(056)-022-8631","dob":{"age":34,"date":"1953-11-04T01:21:04Z"},"email":"zeyneb.elfring@example.com","gender":"female","id":{"name":"BSN","value":"36180866"},"location":{"city":"Tholen","coordinates":{"latitude":"46.8823","longitude":"175.8856"},"postcode":64509,"state":"groningen","street":"2074 adriaen van ostadelaan","timezone":{"description":"Adelaide, Darwin","offset":"+9:30"}},"login":{"md5":"bafe8cf9d37806a7b13edc218d5ff762","password":"ontario","salt":"QVBKgEjy","sha1":"cacef09ff61072d1c55732963766fa84e919aa7a","sha256":"cc86af47aedbdbb1de73ff10484996fe9785c47c0fc191b7c67eaf71e0782300","username":"smallgorilla897","uuid":"37e30c59-bc79-4172-aac6-e2c640e165fa"},"name":{"first":"Zeyneb","last":"Elfring","title":"mrs"},"nat":"NL","phone":"(209)-143-9697","picture":{"large":"https://randomuser.me/api/portraits/women/37.jpg","medium":"https://randomuser.me/api/portraits/med/women/37.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/women/37.jpg"},"registered":{"age":3,"date":"2014-12-07T06:54:14Z"}}deftest_compare_dicts(dicts_are_same):assertdicts_are_same(RESULT,EXPECTED_DATA)
Package: pytest-diff
A simple plugin to use with pytestThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesReadable diffs for failed testsCustomizable diffs for your classesRequirementspytestdeepdiffpprintppInstallationYou can install “pytest-diff” viapipfromPyPI:$ pip install pytest-diffUsageclassPerson:def__init__(self,name,age,favorites):self.name=nameself.age=ageself.favorites=favoritesdeftest_person():a=Person("Alice",age=21,favorites={"food":"spam","movie":"Life of Brian"})b=Person("Alice",age=21,favorites={"food":"eggs","movie":"Life of Brian"})asserta==bRunningpytestgives:______________________________test_person______________________________deftest_person():a=Person("Alice",age=21,favorites={'food':'spam','movie':'Life of Brian'})b=Person("Alice",age=21,favorites={'food':'eggs','movie':'Life of Brian'})>asserta==bEassertE<test_person.Personobjectat0x7fa326d769e8>E==E<test_person.Personobjectat0x7fa326d76be0>E{'values_changed':{"root.favorites['food']":{'new_value':'spam','old_value':'eggs'}}}examples/test_person.py:11:AssertionErrorTo customize diffs for a specific type, register it with the registry:importpytest_diffclassCar:def__init__(self,make,model,year):self.make=makeself.model=modelself.year=year@pytest_diff.registry.register(Car)defdiff(x,y):return[f"{x.make}vs{y.make}",f"{x.model}vs{y.model}",f"{x.year}vs{y.year}",]deftest_car():c1=Car("Toyota","Prius",2010)c2=Car("Honda","Accord",2009)assertc1==c2Then runningpytestshows your custom diff:deftest_car():c1=Car("Toyota","Prius",2010)c2=Car("Honda","Accord",2009)>assertc1==c2EassertE<test_custom.Carobjectat0x7f0e9b0ccd68>E==E<test_custom.Carobjectat0x7f0e9b0cceb8>EToyotavsHondaEPriusvsAccordE2010vs2009examples/test_custom.py:21:AssertionErrorContributingContributions 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-diff” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-diff-selector
pytest-diff-selectorQuickstartpipinstallpytest-diff-selectorcd[git-project-you-want-scanning]selectorHEAD^# scan last committests/test_something.py::test_01

selectorHEAD# scan unstaged/uncommited worktests/test_something.py::test_01WhyWhen having a long integration tests you want your CI extra smarter and don't waste time on irrelevant testsHowFiguring out which tests are affect by specific code changes
It's scanning all the project python files and build a call
graph using AST, and scans this graph to find paths that are
part to the change (by line numbers from the diff) that leads
to a testCurrently it's only a commandline tool, but it should become a full fledged pytest plugin
Package: pytest-disable-plugin
Disable plugins per testThispytestplugin was generated withCookiecutteralong with@hackebrot’scookiecutter-pytest-plugintemplate.FeaturesDisable pytest plugins for specific tests.RequirementspytestInstallationYou can install “pytest-disable-plugin” viapipfromPyPI:$ pip install pytest-disable-pluginUsageimportpytest@pytest.mark.disable_plugin("some_plugin_name")deftest_something():# This test will unload the plugin during setup and reload it afterwards.assertf()==1deftest_something_else():# This test will use the plugin as normal.assertf()==2ContributingContributions 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-disable-plugin” is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.
Package: pytest-django
Welcome to pytest-django!pytest-django allows you to test your Django project/applications with thepytest testing tool.Quick start / tutorialChangelogFull documentation:https://pytest-django.readthedocs.io/en/latest/Contribution docsVersion compatibility:Django: 3.2, 4.1, 4.2, 5.0 and latest main branch (compatible at the time
of each release)Python: CPython>=3.8 or PyPy 3pytest: >=7.0For compatibility with older versions, use the pytest-django 3.*.* series.Licence: BSDProject maintainers: Andreas Pelme, Floris Bruynooghe and Daniel HahlerAll contributorsGitHub repository:https://github.com/pytest-dev/pytest-djangoIssue trackerPython Package Index (PyPI)Install pytest-djangopip install pytest-djangoWhy would I use this instead of Django’smanage.py testcommand?Running your test suite with pytest-django allows you to tap into the features
that are already present in pytest. Here are some advantages:Manage test dependencies with pytest fixtures.Less boilerplate tests: no need to import unittest, create a subclass with methods. Write tests as regular functions.Database re-use: no need to re-create the test database for every test run.Run tests in multiple processes for increased speed (with the pytest-xdist plugin).Make use of otherpytest plugins.Works with both worlds: Existing unittest-style TestCase’s still work without any modifications.See thepytest documentationfor more information on pytest itself.
Package: pytest-django-ahead
This is a fork frompytest-djangowhere I pick some PR’s that
I find important for my current work. This is not the official pytest-django package, but rather a package that origins
from a release tag, and where changesets from PR’s in the project that has not yet been released are merged in.Any important documentation, with exclusion of the ones listed below (that are not yet apart of pytest-django’s
released packages).Features included that are not in pytest-django 3.0.0An mailoutbox function scoped fixture, that provides a list of mails sent out from djangoAn autouse function scoped fixture, that clears django.contrib.sites.models.SITE_CACHE from keeping cached entriesTravisYou can find build reports by checking the3.0.0-ahead branch from here.Install pytest-djangopip install pytest-django-ahead
Package: pytest-djangoapp
https://github.com/idlesign/pytest-djangoappDescriptionNice pytest plugin to help you with Django pluggable application testing.This exposes some useful tools for Django applications developers to facilitate tests authoring, including:Settings overridingTemplate tags testingUser creationRequest object creationManagement command callsMailingMigrationsMessagesDB queries auditLive server & client UI testingetc.Suitable for testing apps for Django 1.8+.How to useLet’s say you have classical tests placing (inside application directory):package_dir
|__ myapp
|  |__ __init__.py
|  |__ tests
|  |  |__ __init__.py
|  |  |__ conftest.py  <- Configure djangoapp here.
|
|__ setup.pyAdd the following lines intoconftest.pyto configuredjangoappand start using it:# conftest.pyfrompytest_djangoappimportconfigure_djangoapp_pluginpytest_plugins=configure_djangoapp_plugin()Fixtures usage examples can be found in the documentation and the source code.Testing an entire projectDespite the fact thatdjangoappis primarily aimed to reusable
Django applications testing one can use it also to test a project (a set of apps).
For that, pass a dotted settings module path intosettingsargument:pytest_plugins=configure_djangoapp_plugin(settings='myproject.settings.settings_testing',migrate=False,# If you do not want to apply migrations.)What about pytest-djangopytest-djangoappdoes not depend onpytest-django.There are design decisions inpytest-djangothat might make it uncomfortable to work with.It usessetuptoolsentrypoints feature forpytestplugin discovery. It’s not a problem by itself,
but all kinds of bootstrapping with side effects made bypytest-djangojust on startup,
make the plugin a poor choice for cases of system-wide (i.e. not venv) installations.Philosophy that next to no unit test should require DB access may be quite annoying.Some fixtures (e.g.django_assert_num_queries) usability arouse questions.Despite thatpytest-djangois nice, of course.pytest-djangoappfixtures allow the use of Django without marking all relevant tests as needing
a database, as is required by pytest-django which provides thedjango_dbmark and db fixtures.If you havepytest-djangoalready installed, it can be disabled for projects
usingpytest-djangoappby adding the following lines intopytest.ini:# pytest.ini[pytest]addopts=-p no:djangoDocumentationhttp://pytest-djangoapp.readthedocs.org/
Package: pytest-django-docker-pg
pytest-django-docker-pgStarts a dockerized postgresql instance in pytest hook allowingpytest_djangotests, for example, to be run against it.How to use[tool.pytest.ini_options]
addopts = "-p pytest_django_docker_pg --django-docker-pg-image=postgres:16-alpine "# settings.pyimportosDATABASES={"default":{"ENGINE":"django.db.backends.postgresql","NAME":os.getenv("DB_NAME","postgres"),"USER":os.getenv("DB_USER","postgres"),"PASSWORD":os.getenv("DB_PASSWORD","secret"),"HOST":os.getenv("DB_HOST","localhost"),"PORT":os.getenv("DB_PORT","5432"),}}
Package: pytest-django-dotenv
pytest-django-dotenvPytest plugin used to specify dotenv for your tests. This project uses
django-dotenv to load your environment variables from your dotenv file.Installationpip install pytest-django-dotenvSetupBase setup uses.envfile which is placed equally with virtual environment
directory. If you want to change that behavior you have to addenv_pathto yourpytest.inifile which allow you to change path to dotenv file starting from
parent of virtualenv directory.Example:
If we have virtualenv iadirectory and dotenv file is placed in parent ofadirectory then you should add this to yourpytest.inifile.[pytest]
env_path = 
    ../.env