repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spidermiddleware_output_chain.py | tests/test_spidermiddleware_output_chain.py | from testfixtures import LogCapture
from scrapy import Request, Spider
from scrapy.utils.defer import deferred_f_from_coro_f
from scrapy.utils.test import get_crawler
from tests.mockserver.http import MockServer
class _BaseSpiderMiddleware:
def __init__(self, crawler):
self.crawler = crawler
@classm... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_fetch.py | tests/test_command_fetch.py | from __future__ import annotations
from typing import TYPE_CHECKING
from tests.utils.cmdline import proc
if TYPE_CHECKING:
from tests.mockserver.http import MockServer
class TestFetchCommand:
def test_output(self, mockserver: MockServer) -> None:
_, out, _ = proc("fetch", mockserver.url("/text"))
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_pipeline_files.py | tests/test_pipeline_files.py | import dataclasses
import os
import random
import time
import warnings
from abc import ABC, abstractmethod
from datetime import datetime
from ftplib import FTP
from io import BytesIO
from pathlib import Path
from posixpath import split
from shutil import rmtree
from tempfile import mkdtemp
from typing import Any
from u... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_mail.py | tests/test_mail.py | from email.charset import Charset
from io import BytesIO
from twisted.internet import defer
from twisted.internet._sslverify import ClientTLSOptions
from scrapy.mail import MailSender
class TestMailSender:
def test_send(self):
mailsender = MailSender(debug=True)
mailsender.send(
to=[... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_poet.py | tests/test_poet.py | """Tests that make sure parts needed for the scrapy-poet stack work."""
from typing import get_type_hints
from scrapy import Spider
from scrapy.spiders import CrawlSpider, CSVFeedSpider, SitemapSpider, XMLFeedSpider
def test_callbacks():
"""Making sure annotations on all non-abstract callbacks can be resolved."... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_engine_stop_download_headers.py | tests/test_engine_stop_download_headers.py | from __future__ import annotations
from typing import TYPE_CHECKING
from testfixtures import LogCapture
from scrapy.exceptions import StopDownload
from scrapy.utils.defer import deferred_f_from_coro_f
from tests.test_engine import (
AttrsItemsSpider,
CrawlerRun,
DataClassItemsSpider,
DictItemsSpider,... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_stats.py | tests/test_stats.py | from __future__ import annotations
from datetime import datetime
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.extensions.corestats import CoreStats
from scrapy.spiders import Spider
from scrapy.statscollectors import Dummy... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spidermiddleware_start.py | tests/test_spidermiddleware_start.py | from scrapy.http import Request
from scrapy.spidermiddlewares.start import StartSpiderMiddleware
from scrapy.spiders import Spider
from scrapy.utils.defer import deferred_f_from_coro_f
from scrapy.utils.misc import build_from_crawler
from scrapy.utils.test import get_crawler
class TestMiddleware:
@deferred_f_from... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_robotstxt.py | tests/test_downloadermiddleware_robotstxt.py | from __future__ import annotations
import asyncio
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from twisted.internet import error
from twisted.internet.defer import Deferred, DeferredList
from twisted.python import failure
from scrapy.downloadermiddlewares.robotstxt import RobotsTxtMiddle... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_asyncgen.py | tests/test_utils_asyncgen.py | from scrapy.utils.asyncgen import as_async_generator, collect_asyncgen
from scrapy.utils.defer import deferred_f_from_coro_f
class TestAsyncgenUtils:
@deferred_f_from_coro_f
async def test_as_async_generator(self):
ag = as_async_generator(range(42))
results = [i async for i in ag]
asse... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_reactor.py | tests/test_utils_reactor.py | import asyncio
import warnings
import pytest
from scrapy.utils.defer import deferred_f_from_coro_f
from scrapy.utils.reactor import (
_asyncio_reactor_path,
install_reactor,
is_asyncio_reactor_installed,
set_asyncio_event_loop,
)
class TestAsyncio:
def test_is_asyncio_reactor_installed(self, rea... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloader_handler_twisted_http2.py | tests/test_downloader_handler_twisted_http2.py | """Tests for scrapy.core.downloader.handlers.http2.H2DownloadHandler."""
from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any
from unittest import mock
import pytest
from testfixtures import LogCapture
from twisted.internet import defer, error
from twisted.web.error import SchemeNotSu... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_startproject.py | tests/test_command_startproject.py | from __future__ import annotations
import os
import subprocess
import sys
from contextlib import contextmanager
from itertools import chain
from pathlib import Path
from shutil import copytree
from stat import S_IWRITE as ANYONE_WRITE_PERMISSION
import scrapy
from scrapy.commands.startproject import IGNORE
from scrap... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spider_start.py | tests/test_spider_start.py | from __future__ import annotations
import warnings
from asyncio import sleep
from typing import Any
import pytest
from testfixtures import LogCapture
from scrapy import Spider, signals
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.utils.defer import deferred_f_from_coro_f, maybe_deferred_to_futu... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_useragent.py | tests/test_downloadermiddleware_useragent.py | from scrapy.downloadermiddlewares.useragent import UserAgentMiddleware
from scrapy.http import Request
from scrapy.spiders import Spider
from scrapy.utils.test import get_crawler
class TestUserAgentMiddleware:
def get_spider_and_mw(self, default_useragent):
crawler = get_crawler(Spider, {"USER_AGENT": def... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_selector.py | tests/test_selector.py | import weakref
import parsel
import pytest
from packaging import version
from scrapy.http import HtmlResponse, TextResponse, XmlResponse
from scrapy.selector import Selector
PARSEL_VERSION = version.parse(getattr(parsel, "__version__", "0.0"))
PARSEL_18_PLUS = PARSEL_VERSION >= version.parse("1.8.0")
class TestSel... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_request_left.py | tests/test_request_left.py | from twisted.internet.defer import inlineCallbacks
from scrapy.signals import request_left_downloader
from scrapy.spiders import Spider
from scrapy.utils.test import get_crawler
from tests.mockserver.http import MockServer
class SignalCatcherSpider(Spider):
name = "signal_catcher"
def __init__(self, crawler... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spider.py | tests/test_spider.py | from __future__ import annotations
import gzip
import re
import warnings
from datetime import datetime
from io import BytesIO
from logging import ERROR, WARNING
from pathlib import Path
from typing import Any
from unittest import mock
import pytest
from testfixtures import LogCapture
from twisted.internet.defer impor... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_http2_client_protocol.py | tests/test_http2_client_protocol.py | from __future__ import annotations
import json
import random
import re
import string
from ipaddress import IPv4Address
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
from unittest import mock
from urllib.parse import urlencode
import pytest
from pytest_twisted import async_yield_fixture
from twi... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_dependencies.py | tests/test_dependencies.py | import os
import re
from configparser import ConfigParser
from pathlib import Path
import pytest
from twisted import version as twisted_version
class TestScrapyUtils:
def test_pinned_twisted_version(self):
"""When running tests within a Tox environment with pinned
dependencies, make sure that the... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloader_handler_twisted_http11.py | tests/test_downloader_handler_twisted_http11.py | """Tests for scrapy.core.downloader.handlers.http11.HTTP11DownloadHandler."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from scrapy.core.downloader.handlers.http11 import HTTP11DownloadHandler
from tests.test_downloader_handlers_http_base import (
TestHttp11Base,
TestHttpProxyB... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_linkextractors.py | tests/test_linkextractors.py | from __future__ import annotations
import pickle
import re
import pytest
from packaging.version import Version
from w3lib import __version__ as w3lib_version
from scrapy.http import HtmlResponse, XmlResponse
from scrapy.link import Link
from scrapy.linkextractors.lxmlhtml import LxmlLinkExtractor
from tests import g... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_display.py | tests/test_utils_display.py | import builtins
from io import StringIO
from unittest import mock
from scrapy.utils.display import pformat, pprint
value = {"a": 1}
colorized_strings = {
(
(
"{\x1b[33m'\x1b[39;49;00m\x1b[33ma\x1b[39;49;00m\x1b[33m'"
"\x1b[39;49;00m: \x1b[34m1\x1b[39;49;00m}"
)
+ su... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_httpauth.py | tests/test_downloadermiddleware_httpauth.py | import pytest
from w3lib.http import basic_auth_header
from scrapy.downloadermiddlewares.httpauth import HttpAuthMiddleware
from scrapy.http import Request
from scrapy.spiders import Spider
class LegacySpider(Spider):
http_user = "foo"
http_pass = "bar"
class DomainSpider(Spider):
http_user = "foo"
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_link.py | tests/test_link.py | import pytest
from scrapy.link import Link
class TestLink:
def _assert_same_links(self, link1, link2):
assert link1 == link2
assert hash(link1) == hash(link2)
def _assert_different_links(self, link1, link2):
assert link1 != link2
assert hash(link1) != hash(link2)
def tes... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_proxy_connect.py | tests/test_proxy_connect.py | import json
import os
import re
import sys
from pathlib import Path
from subprocess import PIPE, Popen
from urllib.parse import urlsplit, urlunsplit
import pytest
from testfixtures import LogCapture
from twisted.internet.defer import inlineCallbacks
from scrapy.http import Request
from scrapy.utils.test import get_cr... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_request.py | tests/test_utils_request.py | from __future__ import annotations
import json
from hashlib import sha1
from weakref import WeakKeyDictionary
import pytest
from scrapy.http import Request
from scrapy.utils.python import to_bytes
from scrapy.utils.request import (
_fingerprint_cache,
fingerprint,
request_httprepr,
request_to_curl,
)... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_project.py | tests/test_utils_project.py | import os
import warnings
from pathlib import Path
import pytest
from scrapy.utils.misc import set_environ
from scrapy.utils.project import data_path, get_project_settings
@pytest.fixture
def proj_path(tmp_path):
prev_dir = Path.cwd()
project_dir = tmp_path
try:
os.chdir(project_dir)
Pa... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_datatypes.py | tests/test_utils_datatypes.py | import copy
import warnings
from abc import ABC, abstractmethod
from collections.abc import Iterator, Mapping, MutableMapping
import pytest
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.http import Request
from scrapy.utils.datatypes import (
CaseInsensitiveDict,
CaselessDict,
LocalCa... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_extension_telnet.py | tests/test_extension_telnet.py | import pytest
from twisted.conch.telnet import ITelnetProtocol
from twisted.cred import credentials
from twisted.internet.defer import inlineCallbacks
from scrapy.extensions.telnet import TelnetConsole
from scrapy.utils.test import get_crawler
class TestTelnetExtension:
def _get_console_and_portal(self, settings... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_engine_stop_download_bytes.py | tests/test_engine_stop_download_bytes.py | from __future__ import annotations
from typing import TYPE_CHECKING
from testfixtures import LogCapture
from scrapy.exceptions import StopDownload
from scrapy.utils.defer import deferred_f_from_coro_f
from tests.test_engine import (
AttrsItemsSpider,
CrawlerRun,
DataClassItemsSpider,
DictItemsSpider,... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spidermiddleware.py | tests/test_spidermiddleware.py | from __future__ import annotations
from collections.abc import AsyncIterator, Iterable
from inspect import isasyncgen
from typing import TYPE_CHECKING, Any
from unittest import mock
import pytest
from testfixtures import LogCapture
from twisted.internet import defer
from scrapy.core.spidermw import SpiderMiddlewareM... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_template.py | tests/test_utils_template.py | from scrapy.utils.template import render_templatefile
def test_simple_render(tmp_path):
context = {"project_name": "proj", "name": "spi", "classname": "TheSpider"}
template = "from ${project_name}.spiders.${name} import ${classname}"
rendered = "from proj.spiders.spi import TheSpider"
template_path =... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_serialize.py | tests/test_utils_serialize.py | import dataclasses
import datetime
import json
from decimal import Decimal
import attr
import pytest
from twisted.internet import defer
from scrapy.http import Request, Response
from scrapy.utils.serialize import ScrapyJSONEncoder
class TestJsonEncoder:
@pytest.fixture
def encoder(self) -> ScrapyJSONEncoder... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_url.py | tests/test_utils_url.py | import warnings
from importlib import import_module
import pytest
from scrapy.linkextractors import IGNORED_EXTENSIONS
from scrapy.spiders import Spider
from scrapy.utils.url import ( # type: ignore[attr-defined]
_is_filesystem_path,
_public_w3lib_objects,
add_http_if_no_scheme,
guess_scheme,
str... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spidermiddleware_depth.py | tests/test_spidermiddleware_depth.py | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from scrapy.http import Request, Response
from scrapy.spidermiddlewares.depth import DepthMiddleware
from scrapy.spiders import Spider
from scrapy.utils.test import get_crawler
if TYPE_CHECKING:
from collections.abc import Generat... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_http_response.py | tests/test_http_response.py | import codecs
from unittest import mock
import pytest
from packaging.version import Version as parse_version
from w3lib import __version__ as w3lib_version
from w3lib.encoding import resolve_encoding
from scrapy.exceptions import NotSupported
from scrapy.http import (
Headers,
HtmlResponse,
Request,
R... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_pipeline_images.py | tests/test_pipeline_images.py | from __future__ import annotations
import dataclasses
import io
import random
from abc import ABC, abstractmethod
from shutil import rmtree
from tempfile import mkdtemp
from typing import Any
import attr
import pytest
from itemadapter import ItemAdapter
from scrapy.http import Request, Response
from scrapy.item impo... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_http_cookies.py | tests/test_http_cookies.py | from scrapy.http import Request, Response
from scrapy.http.cookies import WrappedRequest, WrappedResponse
from scrapy.utils.httpobj import urlparse_cached
class TestWrappedRequest:
def setup_method(self):
self.request = Request(
"http://www.example.com/page.html", headers={"Content-Type": "tex... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_zz_resources.py | tests/test_zz_resources.py | """Test that certain resources are not leaked during earlier tests."""
from __future__ import annotations
import asyncio
import logging
import pytest
from scrapy.utils.log import LogCounterHandler
def test_counter_handler() -> None:
"""Test that ``LogCounterHandler`` is always properly removed.
It's adde... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_pipelines.py | tests/test_pipelines.py | import asyncio
from typing import Any
import pytest
from twisted.internet.defer import Deferred, fail, succeed
from scrapy import Request, Spider, signals
from scrapy.crawler import Crawler
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.pipelines import ItemPipelineManager
from scrapy.utils.asynci... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_curl.py | tests/test_utils_curl.py | import warnings
from typing import Any
import pytest
from w3lib.http import basic_auth_header
from scrapy import Request
from scrapy.utils.curl import curl_to_request_kwargs
class TestCurlToRequestKwargs:
@staticmethod
def _test_command(curl_command: str, expected_result: dict[str, Any]) -> None:
re... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_toplevel.py | tests/test_toplevel.py | import scrapy
def test_version():
assert isinstance(scrapy.__version__, str)
def test_version_info():
assert isinstance(scrapy.version_info, tuple)
def test_request_shortcut():
from scrapy.http import FormRequest, Request # noqa: PLC0415
assert scrapy.Request is Request
assert scrapy.FormReq... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_defer.py | tests/test_utils_defer.py | from __future__ import annotations
import asyncio
import random
from asyncio import Future
from typing import TYPE_CHECKING, Any
import pytest
from twisted.internet.defer import Deferred, inlineCallbacks, succeed
from scrapy.utils.asyncgen import as_async_generator, collect_asyncgen
from scrapy.utils.defer import (
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloaderslotssettings.py | tests/test_downloaderslotssettings.py | import time
from typing import Any
import pytest
from twisted.internet.defer import inlineCallbacks
from scrapy import Request
from scrapy.core.downloader import Downloader, Slot
from scrapy.crawler import CrawlerRunner
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.utils.defer import deferred_f_f... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_spider.py | tests/test_utils_spider.py | from scrapy import Spider
from scrapy.http import Request
from scrapy.item import Item
from scrapy.utils.spider import iter_spider_classes, iterate_spider_output
class MySpider1(Spider):
name = "myspider1"
class MySpider2(Spider):
name = "myspider2"
def test_iterate_spider_output():
i = Item()
r =... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_scheduler_base.py | tests/test_scheduler_base.py | from __future__ import annotations
from urllib.parse import urljoin
import pytest
from testfixtures import LogCapture
from twisted.internet import defer
from twisted.internet.defer import inlineCallbacks
from scrapy.core.scheduler import BaseScheduler
from scrapy.http import Request
from scrapy.spiders import Spider... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_squeues_request.py | tests/test_squeues_request.py | """
Queues that handle requests
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
import pytest
import queuelib
from scrapy.http import Request
from scrapy.spiders import Spider
from scrapy.squeues import (
FifoMemoryQueue,
LifoMemoryQueue,
Marsh... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_closespider.py | tests/test_closespider.py | from twisted.internet.defer import inlineCallbacks
from scrapy.utils.test import get_crawler
from tests.mockserver.http import MockServer
from tests.spiders import (
ErrorSpider,
FollowAllSpider,
ItemSpider,
MaxItemsAndRequestsSpider,
SlowSpider,
)
class TestCloseSpider:
@classmethod
def ... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_offsite.py | tests/test_downloadermiddleware_offsite.py | import warnings
import pytest
from scrapy import Request, Spider
from scrapy.downloadermiddlewares.offsite import OffsiteMiddleware
from scrapy.exceptions import IgnoreRequest
from scrapy.utils.test import get_crawler
UNSET = object()
@pytest.mark.parametrize(
("allowed_domain", "url", "allowed"),
[
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_squeues.py | tests/test_squeues.py | import pickle
import sys
import pytest
from queuelib.tests import test_queue as t
from scrapy.http import Request
from scrapy.item import Field, Item
from scrapy.loader import ItemLoader
from scrapy.selector import Selector
from scrapy.squeues import (
_MarshalFifoSerializationDiskQueue,
_MarshalLifoSerializa... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/spiders.py | tests/spiders.py | """
Some spiders used for testing and benchmarking
"""
from __future__ import annotations
import asyncio
import time
from urllib.parse import urlencode
from twisted.internet import defer
from scrapy import signals
from scrapy.exceptions import StopDownload
from scrapy.http import Request
from scrapy.item import Ite... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_defaultheaders.py | tests/test_downloadermiddleware_defaultheaders.py | from scrapy.downloadermiddlewares.defaultheaders import DefaultHeadersMiddleware
from scrapy.http import Request
from scrapy.spiders import Spider
from scrapy.utils.python import to_bytes
from scrapy.utils.test import get_crawler
class TestDefaultHeadersMiddleware:
def get_defaults_mw(self):
crawler = get... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_crawl.py | tests/test_command_crawl.py | from __future__ import annotations
from typing import TYPE_CHECKING
from tests.test_commands import TestProjectBase
from tests.utils.cmdline import proc
if TYPE_CHECKING:
from collections.abc import Iterable
from pathlib import Path
class TestCrawlCommand(TestProjectBase):
def crawl(
self, code... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_runspider.py | tests/test_command_runspider.py | from __future__ import annotations
import asyncio
import inspect
import platform
import sys
from typing import TYPE_CHECKING
import pytest
from tests.test_crawler import ExceptionSpider, NoRequestsSpider
from tests.utils.cmdline import proc
if TYPE_CHECKING:
from collections.abc import Iterable
from pathlib... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spidermiddleware_referer.py | tests/test_spidermiddleware_referer.py | from __future__ import annotations
import warnings
from typing import TYPE_CHECKING, Any, cast
from urllib.parse import urlparse
import pytest
from scrapy.downloadermiddlewares.redirect import RedirectMiddleware
from scrapy.http import Request, Response
from scrapy.settings import Settings
from scrapy.spidermiddlewa... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_logstats.py | tests/test_logstats.py | from datetime import datetime
import pytest
from scrapy.extensions.logstats import LogStats
from scrapy.utils.test import get_crawler
from tests.spiders import SimpleSpider
class TestLogStats:
def setup_method(self):
self.crawler = get_crawler(SimpleSpider)
self.spider = self.crawler._create_spi... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_trackref.py | tests/test_utils_trackref.py | from io import StringIO
from time import sleep, time
from unittest import mock
import pytest
from scrapy.utils import trackref
class Foo(trackref.object_ref):
pass
class Bar(trackref.object_ref):
pass
@pytest.fixture(autouse=True)
def clear_refs() -> None:
trackref.live_refs.clear()
def test_forma... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_dupefilters.py | tests/test_dupefilters.py | import hashlib
import shutil
import sys
import tempfile
from pathlib import Path
from warnings import catch_warnings
from testfixtures import LogCapture
from scrapy.core.scheduler import Scheduler
from scrapy.dupefilters import BaseDupeFilter, RFPDupeFilter
from scrapy.exceptions import ScrapyDeprecationWarning
from ... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_check.py | tests/test_command_check.py | from __future__ import annotations
import sys
from io import StringIO
from typing import TYPE_CHECKING
from unittest import TestCase
from unittest.mock import Mock, PropertyMock, call, patch
from scrapy.commands.check import Command, TextTestResult
from tests.test_commands import TestProjectBase
from tests.utils.cmdl... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_scrapy__getattr__.py | tests/test_scrapy__getattr__.py | import warnings
def test_deprecated_concurrent_requests_per_ip_attribute():
with warnings.catch_warnings(record=True) as warns:
from scrapy.settings.default_settings import ( # noqa: PLC0415
CONCURRENT_REQUESTS_PER_IP,
)
assert CONCURRENT_REQUESTS_PER_IP is not None
a... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_request_attribute_binding.py | tests/test_request_attribute_binding.py | from testfixtures import LogCapture
from twisted.internet.defer import inlineCallbacks
from scrapy import Request, signals
from scrapy.http.response import Response
from scrapy.utils.test import get_crawler
from tests.mockserver.http import MockServer
from tests.spiders import SingleRequestSpider
OVERRIDDEN_URL = "ht... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_webclient.py | tests/test_webclient.py | """
Tests borrowed from the twisted.web.client tests.
"""
from __future__ import annotations
from urllib.parse import urlparse
import OpenSSL.SSL
import pytest
from pytest_twisted import async_yield_fixture
from twisted.internet import defer
from twisted.internet.defer import inlineCallbacks
from twisted.internet.te... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_crawl.py | tests/test_crawl.py | from __future__ import annotations
import json
import logging
from ipaddress import IPv4Address
from socket import gethostbyname
from typing import TYPE_CHECKING, Any
from urllib.parse import urlencode, urlparse
import pytest
from testfixtures import LogCapture
from twisted.internet.defer import inlineCallbacks, succ... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_parse.py | tests/test_command_parse.py | from __future__ import annotations
import argparse
import re
from typing import TYPE_CHECKING
import pytest
from scrapy.commands import parse
from scrapy.settings import Settings
from tests.test_commands import TestProjectBase
from tests.utils.cmdline import call, proc
if TYPE_CHECKING:
from pathlib import Path... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_logformatter.py | tests/test_logformatter.py | import logging
import pytest
from testfixtures import LogCapture
from twisted.internet.defer import inlineCallbacks
from twisted.python.failure import Failure
from scrapy.exceptions import DropItem
from scrapy.http import Request, Response
from scrapy.item import Field, Item
from scrapy.logformatter import LogFormatt... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_responsetypes.py | tests/test_responsetypes.py | from scrapy.http import (
Headers,
HtmlResponse,
JsonResponse,
Response,
TextResponse,
XmlResponse,
)
from scrapy.responsetypes import responsetypes
class TestResponseTypes:
def test_from_filename(self):
mappings = [
("data.bin", Response),
("file.txt", Text... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_http_headers.py | tests/test_http_headers.py | import copy
import pytest
from scrapy.http import Headers
class TestHeaders:
def assertSortedEqual(self, first, second, msg=None):
assert sorted(first) == sorted(second), msg
def test_basics(self):
h = Headers({"Content-Type": "text/html", "Content-Length": 1234})
assert h["Content-... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_version.py | tests/test_command_version.py | import scrapy
from tests.utils.cmdline import proc
class TestVersionCommand:
def test_output(self) -> None:
_, out, _ = proc("version")
assert out.strip() == f"Scrapy {scrapy.__version__}"
def test_verbose_output(self) -> None:
_, out, _ = proc("version", "-v")
headers = [line... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_middleware.py | tests/test_middleware.py | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from scrapy import Spider
from scrapy.exceptions import NotConfigured, ScrapyDeprecationWarning
from scrapy.middleware import MiddlewareManager
from scrapy.utils.test import get_crawler
if TYPE_CHECKING:
from scrapy.crawler import... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/pipelines.py | tests/pipelines.py | """
Some pipelines used for testing
"""
class ZeroDivisionErrorPipeline:
def open_spider(self):
1 / 0
def process_item(self, item):
return item
class ProcessWithZeroDivisionErrorPipeline:
def process_item(self, item):
1 / 0
| python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_gz.py | tests/test_utils_gz.py | from gzip import BadGzipFile
from pathlib import Path
import pytest
from w3lib.encoding import html_to_unicode
from scrapy.http import Response
from scrapy.utils.gz import gunzip, gzip_magic_number
from tests import tests_datadir
SAMPLEDIR = Path(tests_datadir, "compressed")
def test_gunzip_basic():
r1 = Respo... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_feedexport.py | tests/test_feedexport.py | from __future__ import annotations
import bz2
import csv
import gzip
import json
import lzma
import marshal
import os
import pickle
import random
import shutil
import string
import sys
import tempfile
import warnings
from abc import ABC, abstractmethod
from collections import defaultdict
from io import BytesIO
from lo... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_extension_statsmailer.py | tests/test_extension_statsmailer.py | from unittest.mock import MagicMock
import pytest
from scrapy import signals
from scrapy.exceptions import NotConfigured
from scrapy.extensions import statsmailer
from scrapy.mail import MailSender
from scrapy.signalmanager import SignalManager
from scrapy.statscollectors import StatsCollector
from scrapy.utils.spide... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_core_downloader.py | tests/test_core_downloader.py | from __future__ import annotations
import warnings
from typing import TYPE_CHECKING, Any, cast
import OpenSSL.SSL
import pytest
from pytest_twisted import async_yield_fixture
from twisted.web import server, static
from twisted.web.client import Agent, BrowserLikePolicyForHTTPS, readBody
from twisted.web.client import... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_iterators.py | tests/test_utils_iterators.py | from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any
import pytest
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.http import Response, TextResponse, XmlResponse
from scrapy.utils.iterators import _body_or_str, csviter, xmliter, xmliter_lxml... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_httpproxy.py | tests/test_downloadermiddleware_httpproxy.py | import os
import pytest
from scrapy.downloadermiddlewares.httpproxy import HttpProxyMiddleware
from scrapy.exceptions import NotConfigured
from scrapy.http import Request
from scrapy.spiders import Spider
from scrapy.utils.test import get_crawler
class TestHttpProxyMiddleware:
failureException = AssertionError ... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware.py | tests/test_downloadermiddleware.py | from __future__ import annotations
import asyncio
from contextlib import asynccontextmanager
from gzip import BadGzipFile
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from twisted.internet.defer import Deferred, succeed
from scrapy.core.downloader.middleware import DownloaderMiddlewareMan... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloader_handler_twisted_http10.py | tests/test_downloader_handler_twisted_http10.py | """Tests for scrapy.core.downloader.handlers.http10.HTTP10DownloadHandler."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from scrapy.core.downloader.handlers.http10 import HTTP10DownloadHandler
from scrapy.http import Request
from scrapy.utils.defer import deferred_f_from_coro... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/__init__.py | tests/__init__.py | """
tests: this package contains all Scrapy unittests
see https://docs.scrapy.org/en/latest/contributing.html#running-tests
"""
import os
import socket
from pathlib import Path
from twisted import version as TWISTED_VERSION
from twisted.python.versions import Version
# ignore system-wide proxies for tests
# which w... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_spidermiddleware_httperror.py | tests/test_spidermiddleware_httperror.py | from __future__ import annotations
import logging
import pytest
from testfixtures import LogCapture
from twisted.internet.defer import inlineCallbacks
from scrapy.http import Request, Response
from scrapy.spidermiddlewares.httperror import HttpError, HttpErrorMiddleware
from scrapy.utils.spider import DefaultSpider
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_console.py | tests/test_utils_console.py | import pytest
from scrapy.utils.console import get_shell_embed_func
try:
import bpython
bpy = True
del bpython
except ImportError:
bpy = False
try:
import IPython
ipy = True
del IPython
except ImportError:
ipy = False
def test_get_shell_embed_func():
shell = get_shell_embed_fun... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_command_shell.py | tests/test_command_shell.py | from __future__ import annotations
import os
import sys
from io import BytesIO
from pathlib import Path
from typing import TYPE_CHECKING, cast
import pytest
from pexpect.popen_spawn import PopenSpawn
from scrapy.utils.reactor import _asyncio_reactor_path
from tests import NON_EXISTING_RESOLVABLE, tests_datadir
from ... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_exporters.py | tests/test_exporters.py | import dataclasses
import json
import marshal
import pickle
import re
import tempfile
from abc import ABC, abstractmethod
from datetime import datetime
from io import BytesIO
from typing import Any
import lxml.etree
import pytest
from itemadapter import ItemAdapter
from scrapy.exporters import (
BaseItemExporter,... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_http_request.py | tests/test_http_request.py | import json
import re
import warnings
import xmlrpc.client
from typing import Any
from unittest import mock
from urllib.parse import parse_qs, unquote_to_bytes
import pytest
from scrapy.http import (
FormRequest,
Headers,
HtmlResponse,
JsonRequest,
Request,
XmlRpcRequest,
)
from scrapy.http.re... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_extension_throttle.py | tests/test_extension_throttle.py | from logging import INFO
from unittest.mock import Mock
import pytest
from scrapy import Request, Spider
from scrapy.exceptions import NotConfigured
from scrapy.extensions.throttle import AutoThrottle
from scrapy.http.response import Response
from scrapy.settings.default_settings import (
AUTOTHROTTLE_MAX_DELAY,
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloader_handlers_http_base.py | tests/test_downloader_handlers_http_base.py | """Base classes for HTTP download handler tests."""
from __future__ import annotations
import gzip
import json
import sys
from abc import ABC, abstractmethod
from contextlib import asynccontextmanager
from http import HTTPStatus
from typing import TYPE_CHECKING, Any
from unittest import mock
import pytest
from testf... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloader_handler_twisted_ftp.py | tests/test_downloader_handler_twisted_ftp.py | from __future__ import annotations
import os
import sys
from abc import ABC, abstractmethod
from pathlib import Path
from tempfile import mkstemp
from typing import TYPE_CHECKING, Any
import pytest
from pytest_twisted import async_yield_fixture
from twisted.cred import checkers, credentials, portal
from scrapy.core.... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_pipeline_media.py | tests/test_pipeline_media.py | from __future__ import annotations
import warnings
from unittest.mock import MagicMock
import pytest
from testfixtures import LogCapture
from twisted.python.failure import Failure
from scrapy import signals
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.http import Request, Response
from scrapy.h... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_asyncio.py | tests/test_utils_asyncio.py | from __future__ import annotations
import asyncio
import random
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from twisted.internet.defer import Deferred
from scrapy.utils.asyncgen import as_async_generator
from scrapy.utils.asyncio import (
AsyncioLoopingCall,
_parallel_asyncio,
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_signals.py | tests/test_signals.py | import pytest
from twisted.internet.defer import inlineCallbacks
from scrapy import Request, Spider, signals
from scrapy.utils.defer import deferred_f_from_coro_f
from scrapy.utils.test import get_crawler, get_from_asyncio_queue
from tests.mockserver.http import MockServer
class ItemSpider(Spider):
name = "items... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_core_scraper.py | tests/test_core_scraper.py | from __future__ import annotations
from typing import TYPE_CHECKING
from scrapy.utils.defer import deferred_f_from_coro_f
from scrapy.utils.test import get_crawler
from tests.spiders import SimpleSpider
if TYPE_CHECKING:
import pytest
from tests.mockserver.http import MockServer
@deferred_f_from_coro_f
as... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_httpcompression.py | tests/test_downloadermiddleware_httpcompression.py | from gzip import GzipFile
from io import BytesIO
from logging import WARNING
from pathlib import Path
import pytest
from testfixtures import LogCapture
from w3lib.encoding import resolve_encoding
from scrapy.downloadermiddlewares.httpcompression import (
ACCEPTED_ENCODINGS,
HttpCompressionMiddleware,
)
from s... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_response.py | tests/test_utils_response.py | from pathlib import Path
from time import process_time
from urllib.parse import urlparse
import pytest
from scrapy.http import HtmlResponse, Response
from scrapy.utils.python import to_bytes
from scrapy.utils.response import (
_remove_html_comments,
get_base_url,
get_meta_refresh,
open_in_browser,
... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_deprecate.py | tests/test_utils_deprecate.py | import inspect
import warnings
from unittest import mock
from warnings import WarningMessage
import pytest
from scrapy.exceptions import ScrapyDeprecationWarning
from scrapy.utils.deprecate import create_deprecated_class, update_classpath
class MyWarning(UserWarning):
pass
class SomeBaseClass:
pass
clas... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_pqueues.py | tests/test_pqueues.py | import tempfile
import pytest
import queuelib
from scrapy.http.request import Request
from scrapy.pqueues import DownloaderAwarePriorityQueue, ScrapyPriorityQueue
from scrapy.spiders import Spider
from scrapy.squeues import FifoMemoryQueue
from scrapy.utils.misc import build_from_crawler, load_object
from scrapy.util... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_utils_signal.py | tests/test_utils_signal.py | import asyncio
import pytest
from pydispatch import dispatcher
from testfixtures import LogCapture
from twisted.internet import defer
from twisted.internet.defer import inlineCallbacks
from twisted.python.failure import Failure
from scrapy.utils.asyncio import call_later
from scrapy.utils.defer import deferred_from_c... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_pipeline_crawl.py | tests/test_pipeline_crawl.py | from __future__ import annotations
import shutil
from pathlib import Path
from tempfile import mkdtemp
from typing import TYPE_CHECKING, Any
import pytest
from testfixtures import LogCapture
from twisted.internet.defer import inlineCallbacks
from w3lib.url import add_or_replace_parameter
from scrapy import Spider, s... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_downloadermiddleware_redirect.py | tests/test_downloadermiddleware_redirect.py | from itertools import chain, product
import pytest
from scrapy.downloadermiddlewares.httpproxy import HttpProxyMiddleware
from scrapy.downloadermiddlewares.redirect import (
MetaRefreshMiddleware,
RedirectMiddleware,
)
from scrapy.exceptions import IgnoreRequest
from scrapy.http import HtmlResponse, Request, ... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | true |
scrapy/scrapy | https://github.com/scrapy/scrapy/blob/d1bd8eb49f7aba9289e4ff692006cead8bcd9080/tests/test_contracts.py | tests/test_contracts.py | from unittest import TextTestResult
import pytest
from twisted.internet.defer import inlineCallbacks
from twisted.python import failure
from scrapy import FormRequest
from scrapy.contracts import Contract, ContractsManager
from scrapy.contracts.default import (
CallbackKeywordArgumentsContract,
MetadataContra... | python | BSD-3-Clause | d1bd8eb49f7aba9289e4ff692006cead8bcd9080 | 2026-01-04T14:38:41.023839Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.