Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_multiple_matches(self):
"""Test that multiple matches are found correctly."""
assert len(
chk("""abc and abc are as easy as 123""",
self.l, self.err, self.msg)) == 2
assert len(
chk("""ABC and abc are as easy as 123""",
self.l, self.err, self.msg, ignore_case=True)) == 2
assert chk(
"""abcabc are easy as 123""", self.l, self.err, self.msg) == []
def this_check(self):
"""Boilerplate."""
return chk
def test_starting_with_lowercase_but_is_error(self):
"""Starting with lowercase but should be an error."""
text = 'but I don\'t know what to say?'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 1)
def test_starting_with_But_is_error(self):
"""Starting with but should be an error."""
text = 'But I don\'t know what to say?'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 1)
def test_but_in_middle_of_paragraph(self):
"""But in the middle of a sentence is ok."""
text = 'I\'ve got nothing but nice things to say.'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 0)
def test_but_after_a_newline(self):
"""But after a newline should be an error."""
text = '\nBut what more.'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 1)
def test_starts_with_valid_word(self):
"""Starting with a valid word is not an error."""
text = 'Hello.'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 0)
def test_but_after_a_newline_and_whitespace(self):
"""But after a newline and whitespace should be an error."""
text = '\n But what more.'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 1)
def test_butcher_is_ok(self):
"""Butcher is not an error, even though it has a But."""
text = 'Butchers are ok.'
errors = but.check_dont_start_with_buts(text)
assert_equals(len(errors), 0)
def test_50_Cent_hyphenation(self):
"""Don't flag 50's when it refers to 50 Cent's manager."""
text = """
Dr. Dre suggested to 50's manager that he look into signing
Eminem to the G-Unit record label.
"""
errors = dates.check_decade_apostrophes_short(text)
assert len(errors) == 0