``aspectlib`` is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing
aspectlib is an aspect-oriented programming, monkey-patch and decorators library. It is useful when changing behavior in existing code is desired. It includes tools for debugging and testing: simple mock/record and a complete capture/replay framework.
- Free software: BSD 2-Clause License
pip install aspectlib
Docs are hosted at readthedocs.org: python-aspectlib docs.
Weaving functions, methods, instances and classes is completed.
- “Concerns” (see docs/todo.rst)
If aspectlib.weave doesn’t work for your scenario please report a bug!
|Runtime:||Python 2.6, 2.7, 3.3, 3.4 or PyPy|
Python 3.2, 3.1 and 3.0 are NOT supported (some objects are too crippled).
- function_trace - extremely simple
- Remove some debug leftover prints from v1.5.0.
- Fixed weave to stop reading attributes that don’t match the method selector. Contributed by Jonas Maurus in #14.
- Added support for Python 3.7 and 3.8 (async def functions and generators).
- Fix forgotten debug prints.
- Fixed weaving of objects that don’t live on root-level modules.
- Corrected weaving of methods, the weaved function should be unbound.
- Rolling back only applies undos once.
- Added a convenience weave fixture for pytest.
- Fixed typo in ABSOLUTELLY_ALL_METHODS name (now ABSOLUTELY_ALL_METHODS). Old name is still there for backwards compatibility.
- Fixed another tricky bug in the generator advising wrappers - result was not returned if only Proceed was yielded.
- Corrected result handling when using Aspects on generators.
- Added messages property to aspectlib.test.LogCapture. Change call to have level name instead of number.
- Fixed a bogus warning from aspectlib.patch_module` when patching methods on old style classes.
- Added support for weakrefs in the __logged__ wrapper from aspectlib.debug.log decorator.
- Don’t raise exceptions from Replay.__exit__ if there would be an error (makes original cause hard to debug).
- Fixed weaving methods that were defined in some baseclass (and not on the target class).
- Fixed wrong qualname beeing used in the Story/Replay recording. Now used the alias given to the weaver instead of whatever is the realname on the current platform.
- Use ASPECTLIB_DEBUG for every logger in aspectlib.
- Added a bind option to aspectlib.Aspect so you can access the cutpoint from the advisor.
- Replaced automatic importing in aspectlib.test.Replay with extraction of context variables (locals and globals from the calling aspectlib.test.Story). Works better than the previous inference of module from AST of the result.
- All the methods on the replay are now properties: aspectlib.test.Story.diff, aspectlib.test.Story.unexpected and aspectlib.test.Story.missing.
- Added aspectlib.test.Story.actual and aspectlib.test.Story.expected.
- Added an ASPECTLIB_DEBUG environment variable option to switch on debug logging in aspectlib’s internals.
- Reworked the internals aspectlib.test.Story to keep call ordering, to allow dependencies and improved the serialization (used in the diffs and the missing/unexpected lists).
- Renamed history option to calls.
- Renamed call option to iscalled.
- Added callback option.
- Added extended option.
- Allow weaving everything in a module.
- Allow weaving instances of new-style classes.
Added aspectlib.test.Story class for capture-replay and stub/mock testing.
- Use simpler import for the py3support.
- Change aspectlib.debug.log to use aspectlib.Aspect and work as expected with coroutines or generators.
- Fixed aspectlib.debug.log to work on Python 3.4.
- Remove the undocumented aspectlib.Yield advice. It was only usable when decorating generators.
- Add support for decorating generators and coroutines in aspectlib.Aspect.
- Made aspectlib raise better exceptions.
- Fix checks inside aspectlib.debug.log that would inadvertently call __bool__/__nonzero.
- Don’t include __getattribute__ in ALL_METHODS - it’s too dangerous dangerous dangerous dangerous dangerous dangerous … ;)
- Do a more reliable check for old-style classes in debug.log
- When weaving a class don’t weave attributes that are callable but are not actually routines (functions, methods etc)
- Renamed arguments to call_args.
- Renamed arguments_repr to call_args_repr.
- Added call option.
- Fixed issue with logging from old-style methods (object name was a generic “instance”).
Fixed issues with weaving some types of builtin methods.
Allow to apply multiple aspects at the same time.
Validate string targets before weaving. aspectlib.weave('mod.invalid name', aspect) now gives a clear error (invalid name is not a valid identifier)
Various documentation improvements and examples.
- Remove junk from 0.4.0’s source distribution.
- Replaced only_methods, skip_methods, skip_magicmethods options with methods.
- Renamed on_init option to lazy.
- Added aliases option.
- Replaced skip_subclasses option with subclasses.
Fixed weaving methods from a string target.
- First public release.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size aspectlib-1.5.1-py2.py3-none-any.whl (29.5 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size aspectlib-1.5.1.tar.gz (163.3 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for aspectlib-1.5.1-py2.py3-none-any.whl