testFuzzyAMPMProblem is causing us issues

pull/12/head
Bradlee Speice 2018-07-08 15:23:51 -04:00
parent c954a533c3
commit c038178583
2 changed files with 100 additions and 0 deletions

View File

@ -86,6 +86,14 @@ tests = {
'test_fuzzy_tokens_tzinfo': [
'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.'
],
'test_fuzzy_simple': [
'I have a meeting on March 1, 1974', # testFuzzyAMPMProblem
'On June 8th, 2020, I am going to be the first man on Mars', # testFuzzyAMPMProblem
'Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003', # testFuzzyAMPMProblem
'Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset', # testFuzzyAMPMProblem
'Jan 29, 1945 14:45 AM I going to see you there?', # testFuzzyIgnoreAMPM
'2017-07-17 06:15:', # test_idx_check
],
'test_parse_default_ignore': [
],
}
@ -172,6 +180,13 @@ def test_fuzzy_tokens_tzinfo(i, s):
tokens=r_tokens
)
def test_fuzzy_simple(i, s):
d = parse(s, fuzzy=True)
return TEST_FUZZY_SIMPLE.format(i=i, d=d, s=s)
# Here lies all the ugly junk.
TEST_HEADER = '''
extern crate chrono;
@ -449,6 +464,19 @@ fn test_fuzzy_tokens_tzinfo{i}() {{
None, false, HashMap::new());
}}\n'''
TEST_FUZZY_SIMPLE = '''
#[test]
fn test_fuzzy_simple{i}() {{
let info = ParserInfo::default();
let pdt = PyDateTime {{
year: {d.year}, month: {d.month}, day: {d.day},
hour: {d.hour}, minute: {d.minute}, second: {d.second},
micros: {d.microsecond}, tzo: None
}};
parse_fuzzy_and_assert(pdt, None, info, "{s}", None, None, true, false,
None, false, HashMap::new());
}}\n'''
if __name__ == '__main__':
main()

View File

@ -1757,3 +1757,75 @@ fn test_fuzzy_tokens_tzinfo0() {
parse_fuzzy_and_assert(pdt, Some(tokens), info, "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", None, None, true, true,
None, false, HashMap::new());
}
#[test]
fn test_fuzzy_simple0() {
let info = ParserInfo::default();
let pdt = PyDateTime {
year: 1974, month: 3, day: 1,
hour: 0, minute: 0, second: 0,
micros: 0, tzo: None
};
parse_fuzzy_and_assert(pdt, None, info, "I have a meeting on March 1, 1974", None, None, true, false,
None, false, HashMap::new());
}
#[test]
fn test_fuzzy_simple1() {
let info = ParserInfo::default();
let pdt = PyDateTime {
year: 2020, month: 6, day: 8,
hour: 0, minute: 0, second: 0,
micros: 0, tzo: None
};
parse_fuzzy_and_assert(pdt, None, info, "On June 8th, 2020, I am going to be the first man on Mars", None, None, true, false,
None, false, HashMap::new());
}
#[test]
fn test_fuzzy_simple2() {
let info = ParserInfo::default();
let pdt = PyDateTime {
year: 2003, month: 12, day: 3,
hour: 3, minute: 0, second: 0,
micros: 0, tzo: None
};
parse_fuzzy_and_assert(pdt, None, info, "Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003", None, None, true, false,
None, false, HashMap::new());
}
#[test]
fn test_fuzzy_simple3() {
let info = ParserInfo::default();
let pdt = PyDateTime {
year: 2003, month: 12, day: 3,
hour: 3, minute: 0, second: 0,
micros: 0, tzo: None
};
parse_fuzzy_and_assert(pdt, None, info, "Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset", None, None, true, false,
None, false, HashMap::new());
}
#[test]
fn test_fuzzy_simple4() {
let info = ParserInfo::default();
let pdt = PyDateTime {
year: 1945, month: 1, day: 29,
hour: 14, minute: 45, second: 0,
micros: 0, tzo: None
};
parse_fuzzy_and_assert(pdt, None, info, "Jan 29, 1945 14:45 AM I going to see you there?", None, None, true, false,
None, false, HashMap::new());
}
#[test]
fn test_fuzzy_simple5() {
let info = ParserInfo::default();
let pdt = PyDateTime {
year: 2017, month: 7, day: 17,
hour: 6, minute: 15, second: 0,
micros: 0, tzo: None
};
parse_fuzzy_and_assert(pdt, None, info, "2017-07-17 06:15:", None, None, true, false,
None, false, HashMap::new());
}