MCPcopy
hub / github.com/scrapy/scrapy / test_non_pickable_object

Method test_non_pickable_object

tests/test_squeues.py:116–133  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

114 assert r2.meta["request"] is r2
115
116 def test_non_pickable_object(self):
117 q = self.queue()
118 with pytest.raises(
119 ValueError,
120 match=r"Can't (get|pickle) local object|Can't pickle .*: it's not found as",
121 ) as exc_info:
122 q.push(lambda x: x)
123 if sys.version_info >= (3, 14) or hasattr(sys, "pypy_version_info"):
124 assert isinstance(exc_info.value.__context__, pickle.PicklingError)
125 else:
126 assert isinstance(exc_info.value.__context__, AttributeError)
127 sel = Selector(text="<html><body><p>some text</p></body></html>")
128 with pytest.raises(
129 ValueError, match="can't pickle Selector objects"
130 ) as exc_info:
131 q.push(sel)
132 assert isinstance(exc_info.value.__context__, TypeError)
133 q.close()
134
135
136class ChunkSize1PickleFifoDiskQueueTest(PickleFifoDiskQueueTest):

Callers

nothing calls this directly

Calls 4

queueMethod · 0.95
SelectorClass · 0.90
pushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected