Closed Terrance closed 2 months ago
This looks like one of the mock bugs in Python since inspect.signature(MockService.run)
is what raises.
I guess we can apply the proposed workaround. Can you make it a pull request?
+ return inspect.isroutine(obj) and callable(obj) and not isinstance(obj, Mock)
This will then fall through to interpreting MockService.run
as a non-callable variable. How do we feel about that?
For my use case it's acceptable enough -- I only really need the bare minimum for documentation on these classes (namely the class docstring), and having non-descript members for mock objects at least indicates they're present.
Ideally it'd show the signature of the mock's function spec if it has one, though that doesn't seem to be easily accessible (Mock._spec_signature
), and there's probably a whole rabbit hole of other mock "types" to consider. Can we just identify it as a Mock
object somehow?
Expected behavior
I can document classes that include mock object members (for example, when documenting testing utilities).
Actual behavior
Traceback
``` Traceback (most recent call last): File "/usr/bin/pdoc", line 33, inA naive solution would be to just not treat mocks as functions:
To reproduce
Additional info