def _run_it(self, dbinfo):
def _mock_subprocess_call(*args):<EOL><INDENT>self.subprocess_args = list(*args)<EOL>if '<STR_LIT>' in os.environ:<EOL><INDENT>with open(os.environ['<STR_LIT>'], '<STR_LIT:r>') as f:<EOL><INDENT>self.pgpass = f.read().strip()  <EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.pgpass = None<EOL><DEDENT>return <NUM_LIT:0><EOL><DEDENT>self.subprocess_args = None<EOL>self.pgpass = None<EOL>with mock.patch('<STR_LIT>', new=_mock_subprocess_call):<EOL><INDENT>DatabaseClient.runshell_db(dbinfo)<EOL><DEDENT>return self.subprocess_args, self.pgpass<EOL>
That function invokes the runshell command, while mocking
subprocess.call. It returns a 2-tuple with:
- The command line list
- The content of the file pointed by environment PGPASSFILE, or None.