[TIP] How to return fake values of function called from source file?
rockyji3438 at gmail.com
Sat Sep 21 21:44:17 PDT 2019
New here, new to testing. I have to refactor a friends python code.
It uses pyodbc to work (read only) on SQL server. I do not have admin
rights on my computer, so I want to:
1. Intercept calls made to pyodbc's cursor.execute(), and return fictional
data **based** on the string argument passed (I have already written a
module that can generate random text/blobs as demanded) (the arg is always
2. Fool pyodbc into thinking that it did connect SQL Server.
How do I accomplish this? I read many docs & I can write simple test I but
don't understand how to use pytest.monkeypatch or unittest.mock to
accomplish either 1 or 2.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python