Skip to main content

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.

Project description

docs

Documentation Status

tests

Travis-CI Build Status AppVeyor Build Status Requirements Status
Coverage Status Coverage Status
Code Quality Status Scrutinizer Status Codacy Code Quality Status CodeClimate Quality Status

package

PyPI Package latest release PyPI Package monthly downloads PyPI Wheel Supported versions Supported imlementations

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 license

Documentation

Docs are hosted at readthedocs.org: python-aspectlib docs.

Implementation status

Weaving functions, methods, instances and classes is completed.

Pending:

  • “Concerns” (see docs/todo.rst)

If aspectlib.weave doesn’t work for your scenario please report a bug !

Requirements

OS:

Any

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).

Similar projects

Changelog

1.3.3 (2015-10-02)

  • Fixed typo in ABSOLUTELLY_ALL_METHODS name (now ABSOLUTELY_ALL_METHODS). Old name is still there for backwards compatibility.

1.3.2 (2015-09-22)

  • Fixed another tricky bug in the generator advising wrappers - result was not returned if only Proceed was yielded.

1.3.1 (2015-09-12)

  • Corrected result handling when using Aspects on generators.

1.3.0 (2015-06-06)

  • 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.

1.2.2 (2014-11-25)

  • Added support for weakrefs in the __logged__ wrapper from aspectlib.debug.log decorator.

1.2.1 (2014-10-15)

  • Don’t raise exceptions from Replay.__exit__ if there would be an error (makes original cause hard to debug).

1.2.0 (2014-06-24)

  • 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.

1.1.1 (2014-06-14)

  • Use ASPECTLIB_DEBUG for every logger in aspectlib.

1.1.0 (2014-06-13)

  • 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.

1.0.0 (2014-05-03)

  • 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).

0.9.0 (2014-04-16)

  • Changed aspectlib.test.record:

    • Renamed history option to calls.

    • Renamed call option to iscalled.

    • Added callback option.

    • Added extended option.

  • Changed aspectlib.weave:

    • 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.

0.8.1 (2014-04-01)

  • Use simpler import for the py3support.

0.8.0 (2014-03-31)

  • 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.

0.7.0 (2014-03-28)

  • Add support for decorating generators and coroutines in aspectlib.Aspect.

  • Made aspectlib raise better exceptions.

0.6.1 (2014-03-22)

  • Fix checks inside aspectlib.debug.log that would inadvertently call __bool__/__nonzero.

0.6.0 (2014-03-17)

  • 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)

0.5.0 (2014-03-16)

  • Changed aspectlib.debug.log:

    • 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.

0.4.1 (2014-03-08)

  • Remove junk from 0.4.0’s source distribution.

0.4.0 (2014-03-08)

  • Changed aspectlib.weave:

    • 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.

0.3.1 (2014-03-05)

  • ???

0.3.0 (2014-03-05)

  • First public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aspectlib-1.3.3.tar.gz (158.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aspectlib-1.3.3-py2.py3-none-any.whl (31.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file aspectlib-1.3.3.tar.gz.

File metadata

  • Download URL: aspectlib-1.3.3.tar.gz
  • Upload date:
  • Size: 158.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aspectlib-1.3.3.tar.gz
Algorithm Hash digest
SHA256 b7d9575363d0ffe258c2dc4b1e781cbdbbc75d9ebd8ad4271f449f76a6b31993
MD5 aaa6f4c3a8e4dc45a21a148c4f9eeb6c
BLAKE2b-256 ab7362ff70780aa85101a52945e1873104f9c4508e3c89e393d90fd1d653fc8f

See more details on using hashes here.

File details

Details for the file aspectlib-1.3.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aspectlib-1.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e28dd4bb7fac05a26c9215cfbb877af48c06754f0fd69f909186594bc424cac8
MD5 01dad4159cfbc3bf856c778de632b588
BLAKE2b-256 728dfb2f92e5012a3b864403b875fdfe134f1d2d81a234af1c25980c378d8344

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page