(self, *args, commands=())
| 75 | PS2 = "... " |
| 76 | |
| 77 | def run_cli(self, *args, commands=()): |
| 78 | with ( |
| 79 | captured_stdin() as stdin, |
| 80 | captured_stdout() as stdout, |
| 81 | captured_stderr() as stderr, |
| 82 | self.assertRaises(SystemExit) as cm |
| 83 | ): |
| 84 | for cmd in commands: |
| 85 | stdin.write(cmd + "\n") |
| 86 | stdin.seek(0) |
| 87 | cli(args) |
| 88 | |
| 89 | out = stdout.getvalue() |
| 90 | err = stderr.getvalue() |
| 91 | self.assertEqual(cm.exception.code, 0, |
| 92 | f"Unexpected failure: {args=}\n{out}\n{err}") |
| 93 | return out, err |
| 94 | |
| 95 | def test_interact(self): |
| 96 | out, err = self.run_cli() |
no test coverage detected