def test_byline_to_names_semicolon_seperated_names_and_for(): names = byline_to_names( 'Sara Malm;Annette Witheridge;Ian Drury for the Daily Mail;' 'Daniel Bates') assert len(names) == 4 assert names[2][0] == 'Ian' assert names[2][1] == 'Drury'
def test_in_in_byline(self): byline = (' By Erika Solomon in Beirut and Borzou Daragahi,' ' Middle East correspondent') names = byline_to_names(byline) self.assertEqual(len(names), 2) self.assertEqual(names[0][0], 'Erika') self.assertEqual(names[1][0], 'Borzou')
def test_semicolon_seperated_names_and_for(self): names = byline_to_names( 'Sara Malm;Annette Witheridge;Ian Drury for the Daily Mail;' 'Daniel Bates') self.assertEqual(len(names), 4) self.assertEqual(names[2][0], 'Ian') self.assertEqual(names[2][1], 'Drury')
def test_byline_to_names_in_in_byline(): byline = ( ' By Erika Solomon in Beirut and Borzou Daragahi,' ' Middle East correspondent' ) names = byline_to_names(byline) assert len(names) == 2 assert names[0][0] == 'Erika' assert names[1][0] == 'Borzou'
def test_semicolon_seperated_names_and_for(self): byline = ( 'Sara Malm;Annette Witheridge;Ian Drury for the Daily Mail;' 'Daniel Bates' ) names = byline_to_names(byline) self.assertEqual(len(names), 4) self.assertEqual(names[2][0], 'Ian') self.assertEqual(names[2][1], 'Drury')
def test_in_in_byline(self): byline = ( ' By Erika Solomon in Beirut and Borzou Daragahi,' ' Middle East correspondent' ) names = byline_to_names(byline) self.assertEqual(len(names), 2) self.assertEqual(names[0][0], 'Erika') self.assertEqual(names[1][0], 'Borzou')
def test_byline_to_names_byline_ends_with_comma(): names = byline_to_names('by \n Tony Smith, \n') assert len(names) == 1 assert names[0][0] == 'Tony'
def test_byline_to_names_two_author_seperated_by_comma(): names = byline_to_names('\n By Roger Highfield, Science Editor \n') assert len(names) == 1 assert names[0][0] == 'Roger'
def test_the_triggers_nofirst_fulllast(self): # https://www.nytimes.com/2016/01/08/opinion/a-shameful-round-up-of-refugees.html?_r=0 first, last = byline_to_names('THE EDITORIAL BOARD')[0] self.assertEqual(first, '') self.assertEqual(last, 'The Editorial Board')
def test_newline_after_and(self): names = byline_to_names('\nIan Sample and \nStuart Clark in Darmstadt') self.assertEqual(len(names), 2) self.assertEqual(names[1][1], 'Clark')
def test_the_triggers_nofirst_fulllast(self): # https://www.nytimes.com/2016/01/08/opinion/a-shameful-round-up-of-refugees.html?_r=0 first, last = byline_to_names('THE EDITORIAL BOARD')[0] self.assertEqual(first, '') self.assertEqual(last, 'The Editorial Board')
def test_byline_ends_with_comma(self): names = byline_to_names('by \n Tony Smith, \n') self.assertEqual(len(names), 1) self.assertEqual(names[0][0], 'Tony')
def test_two_author_seperated_by_comma(self): names = byline_to_names('\n By Roger Highfield, Science Editor \n') self.assertEqual(len(names), 1) self.assertEqual(names[0][0], 'Roger')
def test_byline_ends_with_comma(self): byline = 'by \n Tony Smith, \n' names = byline_to_names(byline) self.assertEqual(len(names), 1) self.assertEqual(names[0][0], 'Tony')
def test_two_author_seperated_by_comma(self): byline = '\n By Roger Highfield, Science Editor \n' names = byline_to_names(byline) self.assertEqual(len(names), 1) self.assertEqual(names[0][0], 'Roger')
def test_byline_to_names_newline_after_and(): names = byline_to_names('\nIan Sample and \nStuart Clark in Darmstadt') assert len(names) == 2 assert names[1][1] == 'Clark'
def test_byline_to_names_the_triggers_nofirst_fulllast(): # https://www.nytimes.com/2016/01/08/opinion/a-shameful-round-up-of-refugees.html?_r=0 first, last = byline_to_names('THE EDITORIAL BOARD')[0] assert first == '' assert last == 'The Editorial Board'
def test_newline_after_and(self): byline = '\nIan Sample and \nStuart Clark in Darmstadt' names = byline_to_names(byline) self.assertEqual(len(names), 2) self.assertEqual(names[1][1], 'Clark')