Can you mock a C function using ctypes?
Grant Edwards
grant.b.edwards at gmail.com
Thu Sep 15 15:41:40 EDT 2022
I've done unit testing of C functions using ctypes, and that works
nicely until you need to provide a stub/mock function to be called by
the C code under test.
Can that be done using ctypes?
For example, I open a library that contains functon foo() where foo()
calls external function bar() which is not contained in the library.
Then, I provide a Python bar() function that gets called by foo() when
foo() is called?
I suspect the anser is "no".
I did a bit of googling, and found this question asked on Stack
Overflow a few years ago, but the answer made no sense. It appeared to
be ansering a different question, but I couldn't quite figure out what
that question was.
--
Grant
More information about the Python-list
mailing list