def __call__(self): # type: () -> None command = self._command schema = self._schema process = Popen(command, stdin=PIPE, stdout=PIPE, stderr=STDOUT) # Simulate manually typing the schema in. # Didn't find any other way to pass the schema (eg --query="file /path/to/schema.sql" won't work). process.communicate(ensure_bytes(schema)) process.wait() if process.returncode != 0: raise SubprocessError('Command: {}\nExit code: {}'.format( command, process.returncode))
def test_ensure_bytes(self): assert ensure_bytes('qwerty') == b'qwerty'
def test_ensure_bytes_py2(self): assert ensure_bytes('éâû') == 'éâû' assert ensure_bytes(u'éâû') == 'éâû'