]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
cephadm: add a new funkypatch fixture based on mock.patch and pytest
authorJohn Mulligan <jmulligan@redhat.com>
Sun, 20 Aug 2023 17:50:00 +0000 (13:50 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 30 Nov 2023 21:55:50 +0000 (16:55 -0500)
commit3aa16497b3ab88c0c88fa60f58d32fbb8156e4d4
tree003f6f73b21a4ef0ce0dc46127c48819a467c8ad
parent3939201f53d6c6eae23eec1ab83a47d987c18987
cephadm: add a new funkypatch fixture based on mock.patch and pytest

This fixture acts like a combination of mock.patch and pytest's
monkeypatch fixture. It has the additional feature of automatically
finding and patching the same object imported in other modules.  If you
have 'from x import y', where y is a function or class, in both a.py and
b.py it will patch both instances (so long as both a and b are already
imported).
This behavior is useful for cephadm because of the heavy use of the
`from x import y` idiom and how cephadm is being actively refactored.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/fixtures.py