Source

Kiva Editor's Assistant / tests / yearold.py

Full commit
from expect import expect

def test_year_old():
    # All of these are taken from actual Kiva loan descriptions
    expect(u'Mahmoud is a 47-year-old married man from Lebanon.')
    expect(u'This is 40 year-old Kadiatu.',
           u'This is 40-year-old Kadiatu.')
    expect(u'Eman is a 32 years old young woman.',
           u'Eman is a 32-year-old young woman.')
    expect(u'Yuliana is a 57 year old lady who is originated from Semarang.',
           u'Yuliana is a 57-year-old lady who is originated from Semarang.')
    expect(u'Sabah is a 28 years old married female from Madaba, Jordan.',
           u'Sabah is a 28-year-old married female from Madaba, Jordan.')

    # These cases are correct and should remain unchanged.
    expect(u'She is 47 years old.')
    expect(u'She is a 47-year-old farmer.')

    # These cases should be changed to have a single token of
    # '47-year-old'.
    expect(u'She is a 47 year old farmer.', u'She is a 47-year-old farmer.')
    expect(u'She is a 47-year old farmer.', u'She is a 47-year-old farmer.')
    expect(u'She is a 47 year-old farmer.', u'She is a 47-year-old farmer.')

    # These should have 'years' changed to 'year' and hyphens inserted.
    expect(ur'She is a 47 years old farmer.', ur'She is a 47-year-old farmer.')  # ok
    expect(ur'She is a 47-years old farmer.', ur'She is a 47-year-old farmer.')  # ok
    expect(ur'She is a 47 years-old farmer.', ur'She is a 47-year-old farmer.')
    expect(ur'She is a 47-years-old farmer.', ur'She is a 47-year-old farmer.')