MCPcopy
hub / github.com/scrapy/scrapy / test_fetch

Method test_fetch

tests/test_command_shell.py:144–163  ·  view source on GitHub ↗
(self, mockserver: MockServer)

Source from the content-addressed store, hash-verified

142
143class TestInteractiveShell:
144 def test_fetch(self, mockserver: MockServer) -> None:
145 args = (
146 sys.executable,
147 "-m",
148 "scrapy.cmdline",
149 "shell",
150 )
151 env = os.environ.copy()
152 env["SCRAPY_PYTHON_SHELL"] = "python"
153 logfile = BytesIO()
154 p = PopenSpawn(args, env=env, timeout=5)
155 p.logfile_read = logfile
156 p.expect_exact("Available Scrapy objects")
157 p.sendline(f"fetch('{mockserver.url('/')}')")
158 p.sendline("type(response)")
159 p.expect_exact("HtmlResponse")
160 p.sendeof()
161 p.wait() # type: ignore[no-untyped-call]
162 logfile.seek(0)
163 assert "Traceback" not in logfile.read().decode()

Callers

nothing calls this directly

Calls 4

waitMethod · 0.80
readMethod · 0.80
copyMethod · 0.45
urlMethod · 0.45

Tested by

no test coverage detected