facebook / facebook/TestSlide

Validate if mock_callable() target has left over references

Open
#58 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted mock(_async)_callable
Dominant language
Python
Stars
149
Forks
62
PR merge metrics
No merged PRs in 30d

Description

mock_constructor has [validation logic](https://github.com/facebookincubator/TestSlide/blob/master/testslide/mock_constructor.py#L275-L295) to find out if the class being mocked has other references that are not from the module where it lives. This is important, as there's no guarantees it is gonna work otherwise.

mock_callable has the same potential problem when mocking functions at modules for example: if there are left over references such as `from module import func`, it will not work.

Let's add such validation to mock_callable so users don't shoot themselves in the foot.

This logic can be added [here](https://github.com/facebookincubator/TestSlide/blob/master/testslide/mock_callable.py#L488).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.