From a8b7c41ae297d0990b47c7f531bab325af0efd01 Mon Sep 17 00:00:00 2001 From: Nash Aschenbath Date: Wed, 25 Nov 2026 19:03:08 +0800 Subject: [PATCH 1/2] Recognize right curly quotes when capitalizing title boundaries --- titlecase/__init__.py | 2 +- titlecase/tests.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/titlecase/__init__.py b/titlecase/__init__.py index fd24431..848cbfe 100755 --- a/titlecase/__init__.py +++ b/titlecase/__init__.py @@ -26,7 +26,7 @@ __version__ = '2.4.1' SMALL = r'a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v\.?|via|vs\.?' -PUNCT = r"""!"“#$%&'‘()*+,\-–‒—―./:;?@[\\\]_`{|}~""" +PUNCT = r"""!"“”#$%&'‘’()*+,\-–‒—―./:;?@[\\\]_`{|}~""" SMALL_WORDS = regex.compile(r'^(%s)$' % SMALL, regex.I) diff --git a/titlecase/tests.py b/titlecase/tests.py index 9265ec0..4b629a0 100644 --- a/titlecase/tests.py +++ b/titlecase/tests.py @@ -416,6 +416,20 @@ def test_technical_acronyms(self): 'Sending UDP Packets Over PPPoE Works Great') +class TestCurlyQuotes(unittest.TestCase): + def test_right_curly_quotes(self): + for source, expected in [ + ('’tis the season', '’Tis the Season'), + ('he said “’tis the season”', 'He Said “’Tis the Season”'), + ('’twas a good day', '’Twas a Good Day'), + ('a title about “the”', 'A Title About “The”'), + ('’the final word', '’The Final Word'), + ('’TIS THE SEASON', '’Tis the Season'), + ]: + with self.subTest(source=source): + self.assertEqual(titlecase(source), expected) + + class TestBlankLines(unittest.TestCase): # Really, it's a bit odd that the default behavior is to delete blank lines, # but that's what it was from day one, so we're kind of stuck with that. From 3ab47160872b2a5543b26e5393e14bf0242743d9 Mon Sep 17 00:00:00 2001 From: Nash Aschenbath Date: Wed, 25 Nov 2026 20:29:48 +0800 Subject: [PATCH 2/2] Keep quote regressions separate from apostrophe tests --- titlecase/tests.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/titlecase/tests.py b/titlecase/tests.py index 4b629a0..fc2ebc1 100644 --- a/titlecase/tests.py +++ b/titlecase/tests.py @@ -416,20 +416,6 @@ def test_technical_acronyms(self): 'Sending UDP Packets Over PPPoE Works Great') -class TestCurlyQuotes(unittest.TestCase): - def test_right_curly_quotes(self): - for source, expected in [ - ('’tis the season', '’Tis the Season'), - ('he said “’tis the season”', 'He Said “’Tis the Season”'), - ('’twas a good day', '’Twas a Good Day'), - ('a title about “the”', 'A Title About “The”'), - ('’the final word', '’The Final Word'), - ('’TIS THE SEASON', '’Tis the Season'), - ]: - with self.subTest(source=source): - self.assertEqual(titlecase(source), expected) - - class TestBlankLines(unittest.TestCase): # Really, it's a bit odd that the default behavior is to delete blank lines, # but that's what it was from day one, so we're kind of stuck with that. @@ -458,5 +444,19 @@ def test_nbsps(self): self.assertEqual(titlecase(s), 'Text With Nonbreaking Spaces') self.assertEqual(titlecase(s, normalise_space_characters=True), 'Text With Nonbreaking Spaces') +class TestCurlyQuotes(unittest.TestCase): + def test_right_curly_quotes(self): + for source, expected in [ + ('’tis the season', '’Tis the Season'), + ('he said “’tis the season”', 'He Said “’Tis the Season”'), + ('’twas a good day', '’Twas a Good Day'), + ('a title about “the”', 'A Title About “The”'), + ('’the final word', '’The Final Word'), + ('’TIS THE SEASON', '’Tis the Season'), + ]: + with self.subTest(source=source): + self.assertEqual(titlecase(source), expected) + + if __name__ == '__main__': unittest.main()