Skip to content

Commit

Permalink
Add test case for iter_lines method
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKey-Pro committed Jan 10, 2025
1 parent 8a104da commit 5e57f9b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions locust/test/test_fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ def test_iter_lines(self):

url = "/streaming/10"

response_mock = MagicMock()
response_mock.iter_content = MagicMock(
return_value=iter(
[
b"<span>0</span>\n",
b"<span>1</span>\n",
b"<span>2</span>\n",
b"<span>3</span>\n",
b"<span>4</span>\n",
b"<span>5</span>\n",
b"<span>6</span>\n",
b"<span>7</span>\n",
b"<span>8</span>\n",
b"<span>9</span>\n",
]
)
)
response_mock.raise_for_status = MagicMock()

session.request = MagicMock(return_value=response_mock)

lines = list(session.iter_lines(url))

expected_lines = [f"<span>{i}</span>" for i in range(10)]
Expand Down

0 comments on commit 5e57f9b

Please sign in to comment.