| 350 | |
| 351 | |
| 352 | def test_server_run_with_repl(caplog, capsys): |
| 353 | record = ( |
| 354 | "sanic.error", |
| 355 | 40, |
| 356 | "Can't start REPL in non-interactive mode. " |
| 357 | "You can only run with --repl in a TTY.", |
| 358 | ) |
| 359 | |
| 360 | def run(): |
| 361 | command = ["fake.server.app", "--repl", f"-p={get_port()}"] |
| 362 | return capture(command, capsys=capsys) |
| 363 | |
| 364 | with patch("sanic.cli.app.is_atty", return_value=True): |
| 365 | result = run() |
| 366 | |
| 367 | assert record not in caplog.record_tuples |
| 368 | assert "Welcome to the Sanic interactive console" in result.err |
| 369 | assert ">>> " in result.out |
| 370 | |
| 371 | run() |
| 372 | assert record in caplog.record_tuples |
| 373 | |
| 374 | |
| 375 | def test_command_no_args(caplog): |