Skip to content

Commit

Permalink
fix(checks): make am_pm check case sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
chreekat authored and Nytelife26 committed Jul 11, 2021
1 parent 53076b2 commit b2d1d26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion proselint/checks/dates_times/am_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def check_lowercase_periods(text):
err = "dates_times.am_pm.lowercase_periods"
msg = "With lowercase letters, the periods are standard."

return existence_check(text, [r"\d{1,2} ?[ap]m"], err, msg)
return existence_check(text, [r"\d{1,2} ?[ap]m"], err, msg,
ignore_case=False)


@memoize
Expand Down
15 changes: 8 additions & 7 deletions tests/test_dates_times_am_pm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for dates_times.am_pm check."""
from __future__ import absolute_import

from proselint.checks.dates_times import am_pm as chk

Expand Down Expand Up @@ -29,6 +28,8 @@ def test_smoke_check_lowercase_periods(self):
"It happened at 7 a.m.") == []
assert chk.check_lowercase_periods(
"It happened at 7 am.") != []
assert chk.check_lowercase_periods(
"On Wed, Sep 21, 2016 at 11:42 AM -0400, X wrote:") == []

def test_smoke_check_spacing(self):
"""Basic smoke test.
Expand Down Expand Up @@ -65,9 +66,9 @@ def test_smoke_check_redundancy(self):
dates_times.am_pm.check_redundancy.
"""
assert chk.check_redundancy(
"Basic smoke phrase without issues.") == []
assert chk.check_redundancy(
"It happened at 7 a.m.") == []
assert chk.check_redundancy(
"It happened at 7a.m. in the morning.") != []
assert len(chk.check_redundancy(
"Basic smoke phrase without issues.")) == 0
assert len(chk.check_redundancy(
"It happened at 7 a.m.")) == 0
assert len(chk.check_redundancy(
"It happened at 7a.m. in the morning.")) == 1
3 changes: 3 additions & 0 deletions tests/test_existence_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def test_multiple_matches(self):
assert len(
chk("""ABC and abc are as easy as 123""",
self.L, self.err, self.msg, ignore_case=True)) == 2
assert len(
chk("""ABC and abc are as easy as 123""",
self.L, self.err, self.msg, ignore_case=False)) == 1
assert chk(
"""abcabc are easy as 123""", self.L, self.err, self.msg) == []

Expand Down

0 comments on commit b2d1d26

Please sign in to comment.