Kgb

Latest version: v7.1.1

Safety actively analyzes 626691 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 3

3.0

=======================

* Added an argument to ``spy_on()`` for specifying an explicit owner class
for unbound methods, and warn if missing.

Python 3.x doesn't have a real way of determining the owning class for
unbound methods, and attempting to spy on an unbound method can end up
causing a number of problems, potentially interfering with spies that
are a subclass or superclass of the spied object.

``spy_on()`` now accepts an ``owner=`` parameter for unbound methods in
order to explicitly specify the class. It will warn if this is missing,
providing details on what it thinks the owner is and the recommended
changes to make to the call.

* Fixed spying on unbound methods originally defined on the parent class
of a specified or determined owning class.

* Fixed spying on old-syle classes (those not inheriting from ``object``)
on Python 2.6 and early versions of 2.7.

2.0.3

==========================

* Added a version classifier for Python 3.7.

* Fixed a regression on Python 2.6.

2.0.2

=======================

* Fixed spying on instances of classes with a custom ``__setattr__``.

* Fixed spying on classmethods defined in the parent of a class.

2.0.1

=========================

* Fixed a regression in spying on classmethods.

* Fixed copying function annotations and keyword-only defaults in Python 3.

* Fixed problems executing some types of functions on Python 3.6.

2.0

=========================

* Added compatibility with Python 3.6.

* Spy methods for standard functions no longer need to be accessed like:

.. code-block:: python

func.spy.last_call

Now you can call them the same way you could with methods:

.. code-block:: python

func.last_call

* The ``args`` and ``kwargs`` information recorded for a spy now correspond to
the function signature and not the way the function was called.

* ``called_with()`` now allows providing keyword arguments to check positional
arguments by name.

* When spying on a function fails for some reason, the error output is a
lot more helpful.

1.1

=========================

* Added ``returned()``, ``last_returned()``, ``raised()``, ``last_raised()``,
``raised_with_message()``, and ``last_raised_with_message()`` methods to
function spies.

See the README for how this works.

* Added ``called_with()``, ``returned()``, ``raised()``, and
``raised_with_message()`` to the individual ``SpyCall`` objects.

These are accessed through ``spy.calls``, and allow for more conveniently
checking the results of specific calls in tests.

* ``called_with()`` and ``last_called_with()`` now accept matching subsets of
arguments.

Any number of leading positional arguments and any subset of keyword
arguments can be specified. Prior to 1.0, subsets of keyword arguments
were supported, but 1.0 temporarily made this more strict.

This is helpful when testing function calls containing many default
arguments or when the function takes ``*args`` and ``**kwargs``.

Page 2 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.