def check_shell(self, command, expected_stdout, expected_stderr):
        process = subprocess.Popen(command,
                                   universal_newlines=True,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        process.wait()
        stdout = invariant_output(process.stdout.read())
        stderr = invariant_output(process.stderr.read())
        stdout_diff = [dl for dl in (difflib.Differ().compare(
            stdout.splitlines(),
            expected_stdout.splitlines())) if not dl[0] == ' ']
        stderr_diff = [dl for dl in (difflib.Differ().compare(
            stderr.splitlines(),
            expected_stderr.splitlines())) if not dl[0] == ' ']
        self.assertEqual(remove_whitespace(str(stdout)),
                         remove_whitespace(str(expected_stdout)),
                         stdout_diff)
        self.assertEqual(remove_whitespace(str(stderr)),
                         remove_whitespace(str(expected_stderr)),
                         stderr_diff)
Assert output of shell command is as expected
dataset/ETHPy150Open duerrp/pyexperiment/tests/test_examples.py/TestExamples.check_shell