facebook/TestSlide

Validate if mock_callable() target has left over references

Open

#58 opened on Oct 25, 2019

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Python (58 forks)auto 404
enhancementhelp wantedmock(_async)_callable

Repository metrics

Stars
 (147 stars)
PR merge metrics
 (PR metrics pending)

Description

mock_constructor has validation logic 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.

Contributor guide