akoumjian / datefinder

Find dates inside text using Python and get back datetime objects
http://datefinder.readthedocs.org/en/latest/
MIT License
635 stars 167 forks source link

Unit Tests failing? (add newline added as delimiter) #73

Open petegordon opened 6 years ago

petegordon commented 6 years ago

Hi, been going through the code and decide to run the unit test. Got 6 Errors. I think I saw the fix for 3 of the errors. Change line 47 to

    spy.assert_called_with(expected_parse_arg, default=None)

But, just wanted to make others aware of them problem. And, open an issue. I'm not certain how to fix the remain unit tests.

On another note. I found the testText pattern below does not work with the current implementation. It only picks up the first date.

testText = """ ---Start Date Test---

Label 01 November 2017

Label 02 November 2017

Date 03 November 2017

Date 04 November 2017

---End Date Text--- """

It needs a deliminator other than newlines (like a period) to pick up the dates other than the first one. If you change the code so that it adds \n to the DELIMITERS_PATTERN then it will work. But, I'm afraid that may break multi-line date reads; but I'm not certain.

DELIMITERSPATTERN = '[/\:-\,\s\+\@\n]+'