diff --git a/tests/test_command_shell.py b/tests/test_command_shell.py index 5dcf2f519..cf8b0ec60 100644 --- a/tests/test_command_shell.py +++ b/tests/test_command_shell.py @@ -159,7 +159,9 @@ class TestInteractiveShell: p.expect_exact("HtmlResponse") p.sendeof() p.wait() # type: ignore[no-untyped-call] - p.proc.stdin.close() - p.proc.stdout.close() + if p.proc.stdin: + p.proc.stdin.close() + if p.proc.stdout: + p.proc.stdout.close() logfile.seek(0) assert "Traceback" not in logfile.read().decode() diff --git a/tests/test_crawler_subprocess.py b/tests/test_crawler_subprocess.py index caedb7700..e3f9ac161 100644 --- a/tests/test_crawler_subprocess.py +++ b/tests/test_crawler_subprocess.py @@ -215,8 +215,10 @@ class TestCrawlerProcessSubprocessBase(ScriptRunnerMixin): p.expect_exact("shutting down gracefully") p.expect_exact("Spider closed (shutdown)") p.wait() # type: ignore[no-untyped-call] - p.proc.stdin.close() - p.proc.stdout.close() + if p.proc.stdin: + p.proc.stdin.close() + if p.proc.stdout: + p.proc.stdout.close() def test_shutdown_graceful(self) -> None: self._test_shutdown_graceful() @@ -234,8 +236,10 @@ class TestCrawlerProcessSubprocessBase(ScriptRunnerMixin): p.kill(sig) p.expect_exact("forcing unclean shutdown") p.wait() # type: ignore[no-untyped-call] - p.proc.stdin.close() - p.proc.stdout.close() + if p.proc.stdin: + p.proc.stdin.close() + if p.proc.stdout: + p.proc.stdout.close() @coroutine_test async def test_shutdown_forced(self) -> None: diff --git a/tests/test_extension_telnet.py b/tests/test_extension_telnet.py index f560efb04..20c801558 100644 --- a/tests/test_extension_telnet.py +++ b/tests/test_extension_telnet.py @@ -36,7 +36,7 @@ def _get_console_and_portal( console = TelnetConsole(crawler) # This function has some side effects we don't need for this test - console._get_telnet_vars = dict + console._get_telnet_vars = dict # type: ignore[method-assign] console.start_listening() protocol = console.protocol()