{"categories":[{"label":"Testing","url":"https://skillfed.io/packages/category/software-development-testing/6"}],"enrichment":{"capability":"A pytest plugin that replaces package, module, and attribute dependencies with stubs\u2014either auto-generated (functions, classes, mocks) or custom objects\u2014so you can test code that depends on external libraries without installing them.","skillfed_tags":["pytest-plugin","test-isolation","dependency-mocking"],"use_cases":["Test a library that depends on OpenCV or NumPy without installing those heavy packages in your CI environment.","Isolate tests of Django-related code by stubbing django.core.management and django.conf modules.","Verify that your code handles missing or unavailable dependencies gracefully without actually removing them.","Speed up test runs by replacing slow-to-import or slow-to-initialize external libraries with lightweight stubs.","Test code paths that use optional dependencies without requiring those dependencies to be installed."],"what_it_does":"pytest-stub is a pytest plugin that intercepts imports and replaces external dependencies with stubs\u2014either auto-generated placeholders (functions, classes, mocks) or custom objects you provide. This lets you test code that depends on heavy or unavailable libraries (like OpenCV, Django, or NumPy) without installing them, which is useful when testing a library that uses those dependencies but you want to isolate your test environment.\n\nThe plugin works via a `stub` fixture in individual tests or a global `stub_global()` function in conftest.py. You pass a dictionary mapping import paths to stub types: `'[func]'` generates a function, `'[cls]'` generates a class, `'[mock]'` generates a MagicMock, and `'[mock_persist]'` generates a persistent mock. You can also provide custom objects directly. The stubs are applied before test execution so imports succeed without the actual dependency present.","worth_installing":"Yes, if you need to test code with external dependencies you don't want to install\u2014the plugin is simple and has no runtime dependencies. However, maintenance is abandoned (last release 2020-04-28), so compatibility with Python versions beyond 3.8 is unverified and you should test it in your environment first. For active projects, consider whether a maintained alternative or manual mocking would be more reliable long-term."},"id":"pytest-stub","links":{"html":"https://skillfed.io/packages/pytest-stub","md":"https://skillfed.io/packages/pytest-stub.md","pypi":"https://pypi.org/project/pytest-stub/"},"maintenance":{"status":"abandoned"},"meta":{"latest_release":"2020-04-28","license_spdx":null,"license_treatment":"permissive","name":"pytest-stub","python_support":"unspecified","summary":"Stub packages, modules and attributes."},"popularity":{"monthly_downloads":94774,"position":13307,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"1.1.0"}
