browse: make scrape_links() & scrape_text() "status_code >= 400" error message the same

This commit is contained in:
Itamar Friedman
2023-04-11 11:40:52 +03:00
parent 2d5d0131bb
commit 64c21ee8f7
2 changed files with 2 additions and 2 deletions

View File

@@ -79,7 +79,7 @@ def scrape_links(url):
# Check if the response contains an HTTP error
if response.status_code >= 400:
return "error"
return "Error: HTTP " + str(response.status_code) + " error"
soup = BeautifulSoup(response.text, "html.parser")

View File

@@ -72,7 +72,7 @@ class TestScrapeLinks:
result = scrape_links("https://www.invalidurl.com")
# Assert that the function returns "error"
assert result == "error"
assert "Error:" in result
# Tests that the function returns an empty list when the html contains no hyperlinks.
def test_no_hyperlinks(self, mocker):