-
Notifications
You must be signed in to change notification settings - Fork 11
Description
When rendering templates in Django the template engine will use callable() to decide whether to call a variable to resolve a value. When testing using a Fake object this results in an exception:
RuntimeError: fake:StatusPage object cannot be called (maybe you want Fake.is_callable() ?)
This is because Fake.__call__ is declared even though the fake is not expected to be called, so callable(fake) is always True and the template engine will try to call it.
Took me a while to realise this and come up with a workaround, which is to make sure the fake is callable and just returns itself so the template engine resolves it to itself:
my_fake.expects_call().returns(my_fake)
I'm not sure this is a bug, but I think it's something worth highlighting in the documentation. The documentation doesn't seem to be searchable, but I had a skim through and couldn't find a reference to callable().