Allow expects(...).__call__
Status: Alpha
Brought to you by:
grahamcarlyle
When I want to test class instantiation with a mock, I
cannot simply replace the class by a mock object and do
mock.expects(pmock.once()).__call__(...).will(...),
because the Mock class does not have support for calls.
I realize that adding support for mocking calls would
require some additional code, but it would really be a
cool feature to have.
Logged In: YES
user_id=992618
The version of pmock in CVS does support __call__ ...
class CallableTest(unittest.TestCase):
def test_call_expected(self):
mock = pmock.Mock()
mock.expects(pmock.once()).__call__(pmock.eq("hello"))
mock("hello")
mock.verify()
I intend to release a newer version of pmock but have been
reluctant to until I get the time to think through a few
issues it has, such as supporting properties, more special
methods support, the output format.
To be honest I'm also not entirely certain whether the api
is sufficiently pythonic. The long lines of code that result
from defining an expectation don't seem to sit well with
conventional python formatting.
Added to these issues is the fact that I'm not using it
myself at the moment so I haven't been sufficiently
motivated to move it forward.