<div dir="auto">Hi all,<div dir="auto"><br></div><div dir="auto">New here, new to testing. I have to refactor a friends python code.<div dir="auto"><br></div><div dir="auto">It uses pyodbc to work (read only) on SQL server. I do not have admin rights on my computer, so I want to:</div><div dir="auto"><br></div><div dir="auto"> 1. Intercept calls made to pyodbc&#39;s cursor.execute(), and return fictional data **based** on the string argument passed (I <span style="font-family:sans-serif">have already written a module that can generate random text/blobs as demanded)</span> (the arg is always `select` statment)</div><div dir="auto"> 2. Fool pyodbc into thinking that it did connect SQL Server.</div><div dir="auto"><br></div><div dir="auto">How do I accomplish this? I read many docs &amp; I can write simple test I but don&#39;t understand how to use pytest.monkeypatch or unittest.mock to accomplish either 1 or 2.</div><div dir="auto"><br></div><div dir="auto">Please guide.</div><div dir="auto"><br></div><div dir="auto">Thanks.</div></div></div>