allow referencing mocked classes by the class itself on top of the class name #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Using the class name as a reference when setting up mocks is a handy shortcut that can save a lot of
importstatements. However, it only works well for small projects where there are no collisions between class names. Under the hood, individual mocks are indexed by class name and method name, which makes them vulnerable to collisions.This PR adds support for referencing mocked classes through the class itself, to resolve this limitation.
In larger projects where class names may collide, using direct references allows avoiding mock collisions; the only downside being the need to import all mocked classes explicitly.
Description
some_conflicting_api_test.py) to simulate such collisionsExpect: the current one(class_name, method_name) -> mock, and a new, more robust one(class, method_name) -> mockExpect()statements are defined (forbidding any mix inside a given test)Breaking Changes
None: all existing tests still pass. This PR introduces new and compatible functionality.
Checklist
README.md, docstrings, etc)