Skip to content

Commit

Permalink
Add test for title_case().
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Jul 21, 2020
1 parent 583eec1 commit c363d6d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Color, Info, columns, conjoin, did_you_mean, comment, cull, display, done,
error, Error, fatal, fmt, full_stop, indent, Inform, is_collection,
is_iterable, is_mapping, is_str, join, get_prog_name, get_informer, narrate,
os_error, output, plural, render, terminate, warn, ddd, ppp, sss, vvv,
ProgressBar, parse_range, format_range
os_error, output, plural, render, terminate, title_case, warn, ddd, ppp,
sss, vvv, ProgressBar, parse_range, format_range
)
from textwrap import dedent
import sys
Expand Down Expand Up @@ -185,6 +185,26 @@ def test_did_you_mean():
assert did_you_mean('abc', ['bcd', 'cde']) == 'bcd'
assert did_you_mean('abc', ['cde', 'bcd']) == 'bcd'

def test_title_case():
cases = [(
'CDC warns about "aggressive" rats as coronavirus shuts down restaurants',
'CDC Warns About "Aggressive" Rats as Coronavirus Shuts Down Restaurants'
), (
'L.A. County opens churches, stores, pools, drive-in theaters',
'L.A. County Opens Churches, Stores, Pools, Drive-in Theaters'
), (
'UConn senior accused of killing two men was looking for young woman',
'UConn Senior Accused of Killing Two Men Was Looking for Young Woman'
), (
'Giant asteroid that killed the dinosaurs slammed into Earth at ‘deadliest possible angle,’ study reveals',
'Giant Asteroid That Killed the Dinosaurs Slammed Into Earth at ‘Deadliest Possible Angle,’ Study Reveals'
), (
'Maintain given spacing: This is a test. This is only a test.',
'Maintain Given Spacing: This Is a Test. This Is Only a Test.'
)]
for test, expected in cases:
assert title_case(test) == expected

@pytest.mark.parametrize(
'given, expected', [
('', set()),
Expand Down

0 comments on commit c363d6d

Please sign in to comment.