MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_peek

Method test_peek

Lib/test/test_httplib.py:1612–1641  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1610
1611
1612 def test_peek(self):
1613 resp = self.resp
1614 # patch up the buffered peek so that it returns not too much stuff
1615 oldpeek = resp.fp.peek
1616 def mypeek(n=-1):
1617 p = oldpeek(n)
1618 if n >= 0:
1619 return p[:n]
1620 return p[:10]
1621 resp.fp.peek = mypeek
1622
1623 all = []
1624 while True:
1625 # try a short peek
1626 p = resp.peek(3)
1627 if p:
1628 self.assertGreater(len(p), 0)
1629 # then unbounded peek
1630 p2 = resp.peek()
1631 self.assertGreaterEqual(len(p2), len(p))
1632 self.assertStartsWith(p2, p)
1633 next = resp.read(len(p2))
1634 self.assertEqual(next, p2)
1635 else:
1636 next = resp.read()
1637 self.assertFalse(next)
1638 all.append(next)
1639 if not next:
1640 break
1641 self.assertEqual(b"".join(all), self.lines_expected)
1642
1643 def test_readline(self):
1644 resp = self.resp

Callers

nothing calls this directly

Calls 10

lenFunction · 0.85
assertGreaterMethod · 0.80
assertGreaterEqualMethod · 0.80
assertFalseMethod · 0.80
peekMethod · 0.45
assertStartsWithMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected