Skip to content

Commit

Permalink
Bug: hyphens_with_en_dashes cleans up pipes (#63)
Browse files Browse the repository at this point in the history
* Bug: hyphens_with_en_dashes cleans up pipes

* Bump version

* Trigger notification
  • Loading branch information
AntoineAugusti committed Oct 5, 2020
1 parent 2d31091 commit 13d9c71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion notifications_utils/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

whitespace_before_punctuation = re.compile(r'[ \t]+([,\.])')

hyphens_surrounded_by_spaces = re.compile(r'\s+[-|–|—]{1,3}\s+')
hyphens_surrounded_by_spaces = re.compile(r'\s+[-—]{1,3}\s+')

multiple_newlines = re.compile(r'((\n)\2{2,})')

Expand Down
2 changes: 1 addition & 1 deletion notifications_utils/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '43.0.4'
__version__ = '43.0.5'
# GDS version '34.0.1'
15 changes: 15 additions & 0 deletions tests/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ def test_escaping_govuk_in_email_templates(template_content, expected):
assert expected in str(HTMLEmailTemplate({'content': template_content, 'subject': ''}))


@pytest.mark.parametrize(
"subject,expected", [
("bonjour | hi", "bonjour | hi"),
("bonjour .", "bonjour."),
('double -- dash', 'double \u2013 dash'),
]
)
def test_subject_is_cleaned_up(subject, expected):
assert expected == HTMLEmailTemplate({'content': '', 'subject': subject}).subject


@pytest.mark.parametrize(
"prefix, body, expected", [
("a", "b", "a: b"),
Expand Down Expand Up @@ -960,6 +971,10 @@ def test_smart_quotes(dumb, smart):
'2004-2008',
'2004-2008', # no replacement
),
(
'bonjour | hi',
'bonjour | hi',
),
])
def test_en_dashes(nasty, nice):
assert replace_hyphens_with_en_dashes(nasty) == nice
Expand Down

0 comments on commit 13d9c71

Please sign in to comment.