Skip to content

h4l/prybar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

783b786 · Apr 7, 2019

History

28 Commits
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019
Apr 7, 2019

Repository files navigation

prybar: Create temporary pkg_resources entry points at runtime

CI Status Documentation Status PyPI - Status

A Python library to temporarily define pkg_resources entry points at runtime. The primary use case is testing code which works with entry points.

Installing

$ pip install prybar

prybar requires Python 3.6 or greater.

Usage

>>> import prybar
>>> from pkg_resources import iter_entry_points
>>> # Entry point doesn't exist
>>> list(iter_entry_points('example.hash_types', 'sha256'))
[]
>>> # With prybar's context manager we can create entry points temporarily
>>> with prybar.dynamic_entrypoint('example.hash_types',
...                                name='sha256', module='hashlib'):
...     hash = next(iter_entry_points('example.hash_types', 'sha256')).load()
...     hash(b'foo').hexdigest()[:6]
'2c26b4'
>>> # And it's gone again
>>> list(iter_entry_points('example.hash_types', 'sha256'))
[]

See the full documentation for more.

About

Create temporary pkg_resources entry points at runtime

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages