Reformat long REFERRER_POLICY.

This commit is contained in:
Andrey Rakhmatullin 2025-01-02 18:14:18 +05:00
parent dc706d4fc3
commit 176ae348c5
1 changed files with 16 additions and 3 deletions

View File

@ -891,7 +891,12 @@ class TestSettingsPolicyByName(TestCase):
# test parsing without space(s) after the comma
settings1 = Settings(
{
"REFERRER_POLICY": f"some-custom-unknown-policy,{POLICY_SAME_ORIGIN},{POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN},another-custom-unknown-policy"
"REFERRER_POLICY": (
f"some-custom-unknown-policy,"
f"{POLICY_SAME_ORIGIN},"
f"{POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN},"
f"another-custom-unknown-policy"
)
}
)
mw1 = RefererMiddleware(settings1)
@ -900,7 +905,11 @@ class TestSettingsPolicyByName(TestCase):
# test parsing with space(s) after the comma
settings2 = Settings(
{
"REFERRER_POLICY": f"{POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN}, another-custom-unknown-policy, {POLICY_UNSAFE_URL}"
"REFERRER_POLICY": (
f"{POLICY_STRICT_ORIGIN_WHEN_CROSS_ORIGIN},"
f" another-custom-unknown-policy,"
f" {POLICY_UNSAFE_URL}"
)
}
)
mw2 = RefererMiddleware(settings2)
@ -909,7 +918,11 @@ class TestSettingsPolicyByName(TestCase):
def test_multiple_policy_tokens_all_invalid(self):
settings = Settings(
{
"REFERRER_POLICY": "some-custom-unknown-policy,another-custom-unknown-policy,yet-another-custom-unknown-policy"
"REFERRER_POLICY": (
"some-custom-unknown-policy,"
"another-custom-unknown-policy,"
"yet-another-custom-unknown-policy"
)
}
)
with self.assertRaises(RuntimeError):