{"id":16458226,"url":"https://github.com/boromir674/pytest-object-getter","last_synced_at":"2026-02-04T16:06:42.475Z","repository":{"id":38819467,"uuid":"499103045","full_name":"boromir674/pytest-object-getter","owner":"boromir674","description":"Dynamically import any object from a python (3rd party) module, while mocking its namespace on demand.","archived":false,"fork":false,"pushed_at":"2024-05-23T19:17:21.000Z","size":90,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-03T14:07:38.501Z","etag":null,"topics":["dynamic-import","mocking","monkey-patching","pytest","pytest-fixture","pytest-plugin","python","python-package","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boromir674.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.md","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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-02T11:12:28.000Z","updated_at":"2022-06-27T11:29:00.000Z","dependencies_parsed_at":"2024-11-11T16:49:42.868Z","dependency_job_id":null,"html_url":"https://github.com/boromir674/pytest-object-getter","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":"0.040000000000000036","last_synced_commit":"04ffd935c3e9769c46f439f9f25ed1a28690a9e5"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/boromir674/pytest-object-getter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boromir674%2Fpytest-object-getter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boromir674%2Fpytest-object-getter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boromir674%2Fpytest-object-getter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boromir674%2Fpytest-object-getter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boromir674","download_url":"https://codeload.github.com/boromir674/pytest-object-getter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boromir674%2Fpytest-object-getter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29089921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dynamic-import","mocking","monkey-patching","pytest","pytest-fixture","pytest-plugin","python","python-package","testing"],"created_at":"2024-10-11T10:44:38.386Z","updated_at":"2026-02-04T16:06:42.457Z","avatar_url":"https://github.com/boromir674.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PYTEST OBJECT GETTER\n====================\n\nA Pytest Plugin providing the `get_object` fixture.\n\n.. start-badges\n\n| |build| |docs| |coverage| |maintainability| |better_code_hub| |tech-debt|\n| |release_version| |wheel| |supported_versions| |gh-lic| |commits_since_specific_tag_on_master| |commits_since_latest_github_release|\n\n|\n| **Code:** https://github.com/boromir674/pytest-object-getter\n| **Docs:** https://pytest-object-getter.readthedocs.io/en/master/\n| **PyPI:** https://pypi.org/project/pytest-object-getter/\n| **CI:** https://github.com/boromir674/pytest-object-getter/actions/\n\n\nHighlights\n==========\n\n1. **pytest_object_getter** `python package`, hosted on `pypi.org`_\n\n   - Installable with `pip`\n   -  `get_object` fixture available to your tests\n\n      1. Dynamically import an object from a module\n      2. Optionally mock any object that is present in the module's namespace\n      3. Construct the mock object at runtime\n      4. Alter the bahaviour of an object at runtime\n\n2. Tested against multiple `platforms` and `python` versions\n\n   - platforms: Ubuntu, MacOS\n   - python: 3.6, 3.7, 3.8, 3.9, 3.10\n\n  For more, see the `CI Pipeline`_ and the `Test` workflow, defined in `test.yaml`_.\n\nYou can read more on pytest and fixtures in `pytest latest documentation`_.\n\nQuickstart\n==========\n\nPrerequisites\n-------------\n\nYou need to have `Python` installed.\n\n\nInstalling\n----------\n\nUsing `pip` is the approved way for installing `pytest_object_getter`.\n\n.. code-block:: sh\n\n    python3 -m pip install pytest_object_getter\n\n\nAfter installation the `get_object` pytest fixture should be available in your tests.\n\nA Use Case\n----------\n\nLet's see how to write a test and use the 'get_object' fixture to mock\nthe `requests.get` method to avoid actual network communication:\n\n.. code-block:: shell\n\n    python3 -m pip install ask-pypi\n\n.. code-block:: python\n\n    import pytest\n\n    @pytest.fixture\n    def mock_response():\n        def init(self, package_name: str):\n            self.status_code = 200 if package_name == 'existing-package' else 404\n        return type('MockResponse', (), {\n            '__init__': init\n        })\n\n    @pytest.fixture\n    def create_mock_requests(mock_response):\n        def _create_mock_requests():\n            def mock_get(*args, **kwargs):\n                package_name = args[0].split('/')[-1]\n                return mock_response(package_name)\n            return type('MockRequests', (), {\n                'get': mock_get,\n            })\n        return _create_mock_requests\n\n    def test_fixture(get_object, create_mock_requests):\n\n        from ask_pypi import is_pypi_project\n\n        assert is_pypi_project('numpy') == True\n        assert is_pypi_project('pandas') == True\n        assert is_pypi_project('existing-package') == False\n\n        get_object('is_project', 'ask_pypi.pypi_project',\n            overrides={'requests': lambda: create_mock_requests()})\n\n        assert is_pypi_project('existing-package') == True\n\n        assert is_pypi_project('numpy') == False\n        assert is_pypi_project('pandas') == False\n        assert is_pypi_project('so-magic') == False\n\n\nLicense\n-------\n\nFree software:\n\n* `GNU Affero General Public License v3.0`_\n\n|gh-lic|\n\n\nDevelopment\n===========\n\nHere are some useful notes related to doing development on this project.\n\n1. **Test Suite**, using `pytest`_, located in `tests` dir\n2. **Parallel Execution** of Unit Tests, on multiple cpu's\n3. **Documentation Pages**, hosted on `readthedocs` server, located in `docs` dir\n4. **Automation**, using `tox`_, driven by single `tox.ini` file\n\n   a. **Code Coverage** measuring\n   b. **Build Command**, using the `build`_ python package\n   c. **Pypi Deploy Command**, supporting upload to both `pypi.org`_ and `test.pypi.org`_ servers\n   d. **Type Check Command**, using `mypy`_\n   e. **Lint** *Check* and `Apply` commands, using `isort`_ and `black`_\n5. **CI Pipeline**, running on `Github Actions`_, defined in `.github/`\n\n   a. **Job Matrix**, spanning different `platform`'s and `python version`'s\n\n      1. Platforms: `ubuntu-latest`, `macos-latest`\n      2. Python Interpreters: `3.6`, `3.7`, `3.8`, `3.9`, `3.10`\n   b. **Parallel Job** execution, generated from the `matrix`, that runs the `Test Suite`\n\n\n.. LINKS\n\n.. _tox: https://tox.wiki/en/latest/\n\n.. _pytest: https://docs.pytest.org/en/7.1.x/\n\n.. _build: https://github.com/pypa/build\n\n.. _pypi.org: https://pypi.org/\n\n.. _test.pypi.org: https://test.pypi.org/\n\n.. _mypy: https://mypy.readthedocs.io/en/stable/\n\n.. _isort: https://pycqa.github.io/isort/\n\n.. _black: https://black.readthedocs.io/en/stable/\n\n.. _Github Actions: https://github.com/boromir674/pytest-object-getter/actions\n\n.. _GNU Affero General Public License v3.0: https://github.com/boromir674/pytest-object-getter/blob/master/LICENSE\n\n.. _test.yaml: https://github.com/boromir674/pytest-object-getter/blob/master/.github/workflows/test.yaml\n\n.. _CI Pipeline: https://github.com/boromir674/pytest-object-getter/actions\n\n.. _pytest latest documentation: https://docs.pytest.org/en/latest/\n\n.. BADGE ALIASES\n\n.. Build Status\n.. Github Actions: Test Workflow Status for specific branch \u003cbranch\u003e\n\n.. |build| image:: https://img.shields.io/github/workflow/status/boromir674/pytest-object-getter/Test%20Python%20Package/master?label=build\u0026logo=github-actions\u0026logoColor=%233392FF\n    :alt: GitHub Workflow Status (branch)\n    :target: https://github.com/boromir674/pytest-object-getter/actions/workflows/test.yaml?query=branch%3Amaster\n\n\n.. Documentation\n\n.. |docs| image:: https://img.shields.io/readthedocs/pytest-object-getter/master?logo=readthedocs\u0026logoColor=lightblue\n    :alt: Read the Docs (version)\n    :target: https://pytest-object-getter.readthedocs.io/en/master/\n\n.. Code Coverage\n\n.. |coverage| image:: https://img.shields.io/codecov/c/github/boromir674/pytest-object-getter/master?logo=codecov\n    :alt: Codecov\n    :target: https://app.codecov.io/gh/boromir674/pytest-object-getter\n\n.. PyPI\n\n.. |release_version| image:: https://img.shields.io/pypi/v/pytest_object_getter\n    :alt: Production Version\n    :target: https://pypi.org/project/pytest_object_getter/\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/pytest-object-getter?color=green\u0026label=wheel\n    :alt: PyPI - Wheel\n    :target: https://pypi.org/project/pytest_object_getter\n\n.. |supported_versions| image:: https://img.shields.io/pypi/pyversions/pytest-object-getter?color=blue\u0026label=python\u0026logo=python\u0026logoColor=%23ccccff\n    :alt: Supported Python versions\n    :target: https://pypi.org/project/pytest_object_getter\n\n.. Github Releases \u0026 Tags\n\n.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/pytest-object-getter/v1.0.1/master?color=blue\u0026logo=github\n    :alt: GitHub commits since tagged version (branch)\n    :target: https://github.com/boromir674/pytest-object-getter/compare/v1.0.1..master\n\n.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/boromir674/pytest-object-getter/latest?color=blue\u0026logo=semver\u0026sort=semver\n    :alt: GitHub commits since latest release (by SemVer)\n\n.. LICENSE (eg AGPL, MIT)\n.. Github License\n\n.. |gh-lic| image:: https://img.shields.io/github/license/boromir674/pytest-object-getter\n    :alt: GitHub\n    :target: https://github.com/boromir674/pytest-object-getter/blob/master/LICENSE\n\n\n.. CODE QUALITY\n\n.. Better Code Hub\n.. Software Design Patterns\n\n.. |better_code_hub| image:: https://bettercodehub.com/edge/badge/boromir674/pytest-object-getter?branch=master\n    :alt: Better Code Hub\n    :target: https://bettercodehub.com/\n\n\n.. Code Climate CI\n.. Code maintainability \u0026 Technical Debt\n\n.. |maintainability| image:: https://img.shields.io/codeclimate/maintainability/boromir674/pytest-object-getter\n    :alt: Code Climate Maintainability\n    :target: https://codeclimate.com/github/boromir674/pytest-object-getter/maintainability\n\n.. |tech-debt| image:: https://img.shields.io/codeclimate/tech-debt/boromir674/pytest-object-getter\n    :alt: Technical Debt\n    :target: https://codeclimate.com/github/boromir674/pytest-object-getter/maintainability\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboromir674%2Fpytest-object-getter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboromir674%2Fpytest-object-getter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboromir674%2Fpytest-object-getter/lists"}