def _get_case_dates(self): case_dates = [] for e in self.html.xpath(self.base_path): s = ' '.join(e.xpath(".//text()")) case_date = parse_dates(s)[0] case_dates.extend([case_date] * int(e.xpath("count(./following::ul[1]//li)"))) return case_dates
def test_various_date_extractions(self): test_pairs = ( # Dates separated by semicolons and JUMP words ('February 5, 1980; March 14, 1980 and May 28, 1980.', [ datetime.datetime(1980, 2, 5, 0, 0), datetime.datetime(1980, 3, 14, 0, 0), datetime.datetime(1980, 5, 28, 0, 0) ]), # Misspelled month value. ('Febraury 17, 1945', [datetime.datetime(1945, 2, 17, 0, 0)]), ('Sepetmber 19 1924', [datetime.datetime(1924, 9, 19)]), # Using 'Term' as an indicator. ('November Term 2004.', [datetime.datetime(2004, 11, 01)]), (u'April 26, 1961.[†]', [datetime.datetime(1961, 4, 26)]), ) for pair in test_pairs: dates = parse_dates(pair[0]) self.assertEqual(dates, pair[1])
def test_various_date_extractions(self): test_pairs = ( # Dates separated by semicolons and JUMP words ('February 5, 1980; March 14, 1980 and May 28, 1980.', [datetime.datetime(1980, 2, 5, 0, 0), datetime.datetime(1980, 3, 14, 0, 0), datetime.datetime(1980, 5, 28, 0, 0)]), # Misspelled month value. ('Febraury 17, 1945', [datetime.datetime(1945, 2, 17, 0, 0)]), ('Sepetmber 19 1924', [datetime.datetime(1924, 9, 19)]), # Using 'Term' as an indicator. ('November Term 2004.', [datetime.datetime(2004, 11, 01)]), (u'April 26, 1961.[†]', [datetime.datetime(1961, 4, 26)]), ) for pair in test_pairs: dates = parse_dates(pair[0]) self.assertEqual(dates, pair[1])