{"id":17477720,"url":"https://github.com/mvollrath/pytest-nogarbage","last_synced_at":"2025-03-28T12:10:20.832Z","repository":{"id":62584175,"uuid":"400894767","full_name":"mvollrath/pytest-nogarbage","owner":"mvollrath","description":"Ensure a test produces no garbage.","archived":false,"fork":false,"pushed_at":"2021-08-30T16:30:29.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T23:18:28.058Z","etag":null,"topics":["garbage-collection","pytest","pytest-plugin","python","python3","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvollrath.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-28T21:35:37.000Z","updated_at":"2021-08-30T16:30:32.000Z","dependencies_parsed_at":"2022-11-03T21:38:01.098Z","dependency_job_id":null,"html_url":"https://github.com/mvollrath/pytest-nogarbage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvollrath%2Fpytest-nogarbage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvollrath%2Fpytest-nogarbage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvollrath%2Fpytest-nogarbage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvollrath%2Fpytest-nogarbage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvollrath","download_url":"https://codeload.github.com/mvollrath/pytest-nogarbage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246026111,"owners_count":20711581,"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":["garbage-collection","pytest","pytest-plugin","python","python3","testing"],"created_at":"2024-10-18T20:09:10.737Z","updated_at":"2025-03-28T12:10:20.820Z","avatar_url":"https://github.com/mvollrath.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"================\npytest-nogarbage\n================\n\n.. image:: https://img.shields.io/pypi/v/pytest-nogarbage.svg\n    :target: https://pypi.org/project/pytest-nogarbage\n    :alt: PyPI version\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-nogarbage.svg\n    :target: https://pypi.org/project/pytest-nogarbage\n    :alt: Python 3.7+\n\n.. image:: https://img.shields.io/pypi/implementation/pytest-nogarbage.svg\n    :target: https://pypi.org/project/pytest-nogarbage\n    :alt: CPython\n\n.. image:: https://img.shields.io/pypi/l/pytest-nogarbage.svg\n    :target: https://pypi.org/project/pytest-nogarbage\n    :alt: MIT License\n\nThe purpose of this plugin is ensuring that portions of your Python code do not produce garbage or manually invoke garbage collection.\n\nWhen the `nogarbage` pytest fixture is added to a test, it will cause an error under the following conditions:\n\n* Garbage was collected after the test was run (circular references were remaining after the test was broken down).\n* Garbage was explicitly collected  (`gc.collect()`) during the test.  Automatic garbage collection sweeps are disabled during the test.\n\nYou should use this plugin when:\n\n* You intend to run a program with garbage collection disabled in production.\n* You wish to verify elimination of garbage collection overhead produced by frequently called functions.\n\nThis tool is not for finding memory leaks; even if your code produces no garbage, native call-ins can still leak memory.  Garbage in CPython is specifically circular references between Python objects.\n\nIf you are interested in optimizing CPython garbage collection or unsure of the difference between garbage and memory leaks, the `gc docs`_ and `CPython Garbage Collection devguide`_ are excellent resources.\n\nRequirements\n------------\n\n* Python 3.7+\n* This plugin is only tested against CPython.\n\n\nInstallation\n------------\n\nYou can install \"pytest-nogarbage\" via `pip`_ from `PyPI`_::\n\n    $ pip install pytest-nogarbage\n\n\nUsage\n-----\n\nAdd the `nogarbage` fixture to your test to ensure it does not produce garbage::\n\n    def test_circular(nogarbage):\n        l1 = []\n        l2 = [l1]\n        l1.append(l2)\n        # ERROR: Garbage collected after test.\n\n    def test_collect(nogarbage):\n        import gc\n        gc.collect()\n        # ERROR: Garbage collected during test.\n\n\nRunning the Tests\n-----------------\n\nThis project uses `nox`_ to test against multiple Python versions::\n\n    $ python3 -m venv .venv\n    $ source .venv/bin/activate\n    (.venv) $ pip install nox uv\n    (.venv) $ nox\n\n\nLicense\n-------\n\nDistributed under the terms of the `MIT`_ license, \"pytest-nogarbage\" is free and open source software.\n\n.. _`MIT`: http://opensource.org/licenses/MIT\n.. _`file an issue`: https://github.com/mvollrath/pytest-nogarbage/issues\n.. _`nox`: https://nox.thea.codes/en/stable/\n.. _`pip`: https://pypi.org/project/pip/\n.. _`PyPI`: https://pypi.org/project\n.. _`gc docs`: https://docs.python.org/3/library/gc.html\n.. _`CPython Garbage Collection devguide`: https://devguide.python.org/garbage_collector/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvollrath%2Fpytest-nogarbage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvollrath%2Fpytest-nogarbage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvollrath%2Fpytest-nogarbage/lists"}