MCPcopy
hub / github.com/scrapy/scrapy / test_one_element

Method test_one_element

tests/test_squeues_request.py:44–73  ·  view source on GitHub ↗
(self, q: queuelib.queue.BaseQueue, test_peek: bool)

Source from the content-addressed store, hash-verified

42
43 @pytest.mark.parametrize("test_peek", [True, False])
44 def test_one_element(self, q: queuelib.queue.BaseQueue, test_peek: bool):
45 if test_peek and not HAVE_PEEK:
46 pytest.skip("The queuelib queues do not define peek")
47 if not test_peek and HAVE_PEEK:
48 pytest.skip("The queuelib queues define peek")
49 assert len(q) == 0
50 if test_peek:
51 assert q.peek() is None
52 assert q.pop() is None
53 req = Request("http://www.example.com")
54 q.push(req)
55 assert len(q) == 1
56 if test_peek:
57 result = q.peek()
58 assert result is not None
59 assert result.url == req.url
60 else:
61 with pytest.raises(
62 NotImplementedError,
63 match="The underlying queue class does not implement 'peek'",
64 ):
65 q.peek()
66 result = q.pop()
67 assert result is not None
68 assert result.url == req.url
69 assert len(q) == 0
70 if test_peek:
71 assert q.peek() is None
72 assert q.pop() is None
73 q.close()
74
75 @pytest.mark.parametrize("test_peek", [True, False])
76 def test_order(self, q: queuelib.queue.BaseQueue, test_peek: bool):

Callers

nothing calls this directly

Calls 5

RequestClass · 0.90
peekMethod · 0.45
popMethod · 0.45
pushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected