Giter VIP home page Giter VIP logo

Comments (3)

nicoddemus avatar nicoddemus commented on June 3, 2024

Hi,

Did not take a deep look at the code, but probably is the matter of patching in the wrong place, see Where to patch.

from pytest-mock.

louis030195 avatar louis030195 commented on June 3, 2024

I tried to patch on every single lines without better result :/

PS: maybe related to something with async?

from pytest-mock.

nicoddemus avatar nicoddemus commented on June 3, 2024

If you print the get_user_id at the place where it is used (IOW, where you expect the patch to have changed it) you will notice that it points to the original function, not to a MagicMock object. This might give a clue where you should be patching.

Another thing you can try is to write assert 0 in the line you call mocker.patch and another assert 0 in the line where get_user_id is used: if the latter is hit first, then it means you are patching it too late.

PS: maybe related to something with async?

Don't think so, shouldn't really affect mocking.

from pytest-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.