chore: apply flake8-pytest-style linter rules (#8307)

This commit is contained in:
Bowen Liang
2024-09-12 18:09:16 +08:00
committed by GitHub
parent 40fb4d16ef
commit 8815511ccb
7 changed files with 23 additions and 23 deletions

View File

@@ -13,7 +13,7 @@ CACHED_APP = Flask(__name__)
CACHED_APP.config.update({"TESTING": True})
@pytest.fixture()
@pytest.fixture
def app() -> Flask:
return CACHED_APP

View File

@@ -1,6 +1,8 @@
import random
from unittest.mock import MagicMock, patch
import pytest
from core.helper.ssrf_proxy import SSRF_DEFAULT_MAX_RETRIES, STATUS_FORCELIST, make_request
@@ -22,11 +24,9 @@ def test_retry_exceed_max_retries(mock_request):
side_effects = [mock_response] * SSRF_DEFAULT_MAX_RETRIES
mock_request.side_effect = side_effects
try:
with pytest.raises(Exception) as e:
make_request("GET", "http://example.com", max_retries=SSRF_DEFAULT_MAX_RETRIES - 1)
raise AssertionError("Expected Exception not raised")
except Exception as e:
assert str(e) == f"Reached maximum retries ({SSRF_DEFAULT_MAX_RETRIES - 1}) for URL http://example.com"
assert str(e.value) == f"Reached maximum retries ({SSRF_DEFAULT_MAX_RETRIES - 1}) for URL http://example.com"
@patch("httpx.request")

View File

@@ -1,3 +1,5 @@
import pytest
from libs.helper import email
@@ -9,17 +11,11 @@ def test_email_with_valid_email():
def test_email_with_invalid_email():
try:
with pytest.raises(ValueError, match="invalid_email is not a valid email."):
email("invalid_email")
except ValueError as e:
assert str(e) == "invalid_email is not a valid email."
try:
with pytest.raises(ValueError, match="@example.com is not a valid email."):
email("@example.com")
except ValueError as e:
assert str(e) == "@example.com is not a valid email."
try:
with pytest.raises(ValueError, match="()@example.com is not a valid email."):
email("()@example.com")
except ValueError as e:
assert str(e) == "()@example.com is not a valid email."