{"id":25976764,"url":"https://github.com/dbfixtures/pytest-mongo","last_synced_at":"2025-03-17T02:06:28.862Z","repository":{"id":9837286,"uuid":"63502916","full_name":"dbfixtures/pytest-mongo","owner":"dbfixtures","description":"This is a pytest plugin, that enables you to test your code that relies on a running MongoDB database. It allows you to specify fixtures for MongoDB process and client.","archived":false,"fork":false,"pushed_at":"2025-02-20T17:22:58.000Z","size":1020,"stargazers_count":21,"open_issues_count":3,"forks_count":5,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-02-20T18:30:51.631Z","etag":null,"topics":["hacktoberfest","mongodb","pytest-plugin","python"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/pytest-mongo/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbfixtures.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-16T21:26:55.000Z","updated_at":"2025-02-20T17:23:29.000Z","dependencies_parsed_at":"2023-10-11T07:16:53.730Z","dependency_job_id":"5e637d39-9cf7-436e-8cef-506fff1f11ba","html_url":"https://github.com/dbfixtures/pytest-mongo","commit_stats":{"total_commits":451,"total_committers":10,"mean_commits":45.1,"dds":0.5432372505543237,"last_synced_commit":"1318738f0e7ea00bf4bf0da3d906d9bde373a804"},"previous_names":["dbfixtures/pytest-mongo"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbfixtures%2Fpytest-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbfixtures%2Fpytest-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbfixtures%2Fpytest-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbfixtures%2Fpytest-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbfixtures","download_url":"https://codeload.github.com/dbfixtures/pytest-mongo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960667,"owners_count":20375104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","mongodb","pytest-plugin","python"],"created_at":"2025-03-05T04:11:11.082Z","updated_at":"2025-03-17T02:06:28.845Z","avatar_url":"https://github.com/dbfixtures.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://raw.githubusercontent.com/dbfixtures/pytest-mongo/master/logo.png\n    :width: 100px\n    :height: 100px\n\npytest-mongo\n============\n\n.. image:: https://img.shields.io/pypi/v/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/wheel/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: Wheel Status\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: Supported Python Versions\n\n.. image:: https://img.shields.io/pypi/l/pytest-mongo.svg\n    :target: https://pypi.python.org/pypi/pytest-mongo/\n    :alt: License\n\n\nWhat is this?\n=============\n\nThis is a pytest plugin, that enables you to test your code that relies on a running MongoDB database.\nIt allows you to specify fixtures for MongoDB process and client.\n\nHow to use\n==========\n\nPlugin contains two fixtures\n\n* **mongodb** - it's a client fixture that has functional scope, and which cleans MongoDB at the end of each test.\n* **mongo_proc** - session scoped fixture, that starts MongoDB instance at the first use and stops at the end of the tests.\n* **mongo_noproc** - a no process fixture, that's connecting to already\n  running mongodb instance.\n  For example on dockerized test environments, or CI providing mongodb services\n\nSimply include one of these fixtures into your tests fixture list.\n\nYou can also create additional MongoDB client and process fixtures if you'd need to:\n\n\n.. code-block:: python\n\n    from pytest_mongo import factories\n\n    mongo_my_proc = factories.mongo_proc(\n        port=None, logsdir='/tmp')\n    mongo_my = factories.mongodb('mongo_my_proc')\n\n.. note::\n\n    Each MongoDB process fixture can be configured in a different way than the others through the fixture factory arguments.\n\n\nConnecting to already existing mongodb database\n-----------------------------------------------\n\nSome projects are using already running MongoDB servers (ie on docker instances).\nIn order to connect to them, one would be using the ``mongo_noproc`` fixture.\n\n.. code-block:: python\n\n    mongo_external = factories.mongodb('mongo_noproc')\n\nBy default the  ``mongo_noproc`` fixture would connect to MongoDB instance using **27017** port. Standard configuration options apply to it.\n\nThese are the configuration options that are working on all levels with the ``mongo_noproc`` fixture:\n\nConfiguration\n=============\n\nYou can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option.\nYou can pick which you prefer, but remember that these settings are handled in the following order:\n\n    * ``Fixture factory argument``\n    * ``Command line option``\n    * ``Configuration option in your pytest.ini file``\n\n.. list-table:: Configuration options\n   :header-rows: 1\n\n   * - MongoDB server option\n     - Fixture factory argument\n     - Command line option\n     - pytest.ini option\n     - Noop process fixture\n     - Default\n   * - Path to mongodb exec\n     - executable\n     - --mongo-exec\n     - mongo_exec\n     - no\n     - /usr/bin/mongod\n   * - MongoDB host\n     - host\n     - --mongo-host\n     - mongo_host\n     - 127.0.0.1\n     - 127.0.0.1\n   * - MongoDB port\n     - port\n     - --mongo-port\n     - port\n     - 27017\n     - random\n   * - Path to store logs\n     - logsdir\n     - --mongo-logsdir\n     - mongo_logsdir\n     - no\n     - $TMPDIR\n   * - Additional parameters\n     - params\n     - --mongo-params\n     - mongo_params\n     - no\n     -\n   * - MongoDB client's time zone awarness\n     - tz_aware\n     - --mongo-tz-aware\n     - mongo_tz_aware\n     - no\n     - False\n\n\nExample usage:\n\n* pass it as an argument in your own fixture\n\n    .. code-block:: python\n\n        mongo_proc = factories.mongo_proc(port=8888)\n\n* use ``--mongo-port`` command line option when you run your tests\n\n    .. code-block:: sh\n\n        py.test tests --mongo-port=8888\n\n\n* specify your directory as ``mongo_port`` in your ``pytest.ini`` file.\n\n    To do so, put a line like the following under the ``[pytest]`` section of your ``pytest.ini``:\n\n    .. code-block:: ini\n\n        [pytest]\n        mongo_port = 8888\n\nPackage resources\n-----------------\n\n* Bug tracker: https://github.com/dbfixtures/pytest-mongo/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbfixtures%2Fpytest-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbfixtures%2Fpytest-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbfixtures%2Fpytest-mongo/lists"}