facebook / facebook/TestSlide

Validate if mock_callable() target has left over references

Aperta
#58 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement help wanted mock(_async)_callable
Lingua principale
Python
Stelle
149
Fork
62
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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).

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.