(self, *args, commands=())
| 84 | PS2 = "\001\002 ... \001\002" |
| 85 | |
| 86 | def run_cli(self, *args, commands=()): |
| 87 | with ( |
| 88 | captured_stdin() as stdin, |
| 89 | captured_stdout() as stdout, |
| 90 | captured_stderr() as stderr, |
| 91 | self.assertRaises(SystemExit) as cm |
| 92 | ): |
| 93 | for cmd in commands: |
| 94 | stdin.write(cmd + "\n") |
| 95 | stdin.seek(0) |
| 96 | cli(args) |
| 97 | |
| 98 | out = stdout.getvalue() |
| 99 | err = stderr.getvalue() |
| 100 | self.assertEqual(cm.exception.code, 0, |
| 101 | f"Unexpected failure: {args=}\n{out}\n{err}") |
| 102 | return out, err |
| 103 | |
| 104 | def test_interact(self): |
| 105 | out, err = self.run_cli() |
no test coverage detected