Skip to content

Commit

Permalink
Fix up unnecessarily split strings, which were a side-effect of refor…
Browse files Browse the repository at this point in the history
…matting
  • Loading branch information
stevejalim committed Jan 24, 2024
1 parent f38dd2f commit 3d3fac4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions csp/tests/test_jinja_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_async_attribute_with_falsey(self):
var hello='world';
{% endscript %}"""

expected = '<script nonce="{}" id="jeff" async=false>' "var hello='world';" "</script>"
expected = '<script nonce="{}" id="jeff" async=false>var hello=\'world\';</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))

Expand All @@ -52,7 +52,7 @@ def test_async_attribute_with_truthy(self):
var hello='world';
{% endscript %}"""

expected = '<script nonce="{}" id="jeff" async>' "var hello='world';" "</script>"
expected = '<script nonce="{}" id="jeff" async>var hello=\'world\';</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))

Expand All @@ -66,7 +66,7 @@ def test_nested_script_tags_are_removed(self):
</script>
{% endscript %}"""

expected = "<script" ' nonce="{}" id="jeff" type="application/javascript" defer>' "var hello='world';</script>"
expected = '<script nonce="{}" id="jeff" type="application/javascript" defer>var hello=\'world\';</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))

Expand All @@ -82,6 +82,6 @@ def test_regex_captures_script_content_including_brackets(self):
{% endscript %}
"""

expected = '<script nonce="{}">' 'let capture_text = "<script></script>"' "</script>"
expected = '<script nonce="{}">let capture_text = "<script></script>"</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))
6 changes: 3 additions & 3 deletions csp/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_script_tag_sets_attrs_correctly(self):
var hello='world';
{% endscript %}"""

expected = "<script" ' nonce="{}" id="jeff" type="application/javascript" defer>' "var hello='world';</script>"
expected = '<script nonce="{}" id="jeff" type="application/javascript" defer>var hello=\'world\';</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))

Expand Down Expand Up @@ -65,7 +65,7 @@ def test_nested_script_tags_are_removed(self):
</script>
{% endscript %}"""

expected = "<script" ' nonce="{}" id="jeff" type="application/javascript" defer>' "var hello='world';</script>"
expected = '<script nonce="{}" id="jeff" type="application/javascript" defer>var hello=\'world\';</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))

Expand All @@ -82,6 +82,6 @@ def test_regex_captures_script_content_including_brackets(self):
{% endscript %}
"""

expected = '<script nonce="{}">' 'let capture_text = "<script></script>"' "</script>"
expected = '<script nonce="{}">let capture_text = "<script></script>"</script>'

self.assert_template_eq(*self.process_templates(tpl, expected))
4 changes: 2 additions & 2 deletions csp/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_require_trusted_types_for():
def test_trusted_types():
policy = build_policy()
policy_eq(
"default-src 'self'; trusted-types strictPolicy laxPolicy " + "default 'allow-duplicates'",
"default-src 'self'; trusted-types strictPolicy laxPolicy default 'allow-duplicates'",
policy,
)

Expand All @@ -277,7 +277,7 @@ def test_nonce():
def test_nonce_include_in():
policy = build_policy(nonce="abc123")
policy_eq(
("default-src 'self'; " "script-src 'nonce-abc123'; " "style-src 'nonce-abc123'"),
"default-src 'self'; script-src 'nonce-abc123'; style-src 'nonce-abc123'",
policy,
)

Expand Down

0 comments on commit 3d3fac4

Please sign in to comment.