Django unit testing with date/time-based objects

EDIT: Since my answer is the accepted answer here I’m updating it to let everyone know a better way has been created in the meantime, the freezegun library: https://pypi.python.org/pypi/freezegun. I use this in all my projects when I want to influence time in tests. Have a look at it. Original answer: Replacing internal stuff like … Read more

Possible to stub method twice within a single test to return different results?

Sinon has a nice API for handling multiple calls (stub.onCall(n);) to the same stubbed method. Example from stub api doc: “test should stub method differently on consecutive calls”: function () { var callback = sinon.stub(); callback.onCall(0).returns(1); callback.onCall(1).returns(2); callback.returns(3); callback(); // Returns 1 callback(); // Returns 2 callback(); // All following calls return 3 } You … Read more

What is double method in rspec for?

Edit: I just reread your question and realized I didn’t quite answer it. Leaving my original answer because it’s related, but here’s your specific answer: The reason you don’t need a double is because you’re stubbing class methods, rather than instance methods. double is only useful for dealing with instances of the class, not the … Read more

Testing software: fake vs stub

I assume you are referring to the terminology as introduced by Meszaros. Martin Fowler does also mentions them regularly. I think he explains the difference pretty well in that article. Nevertheless, I’ll try again in my own words 🙂 A Fake is closer to a real-world implementation than a stub. Stubs contain basically hard-coded responses … Read more

techhipbettruvabetnorabahisbahis forumu