From 2b90bf6ed73330d9ccd5cdb68a76454d07f2ec1b Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 2 Jul 2018 23:00:45 -0400 Subject: [PATCH] ...I may be an idiot. --- build_pycompat.py | 10 +++++----- src/lib.rs | 2 +- tests/pycompat.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build_pycompat.py b/build_pycompat.py index 572c5b0..acd48be 100644 --- a/build_pycompat.py +++ b/build_pycompat.py @@ -80,7 +80,7 @@ tests = { '1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z', 'Tue Apr 4 00:22:12 PDT 1995' ], - 'test_fuzzy': [ + 'test_fuzzy_tzinfo': [ 'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.' ], 'test_parse_default_ignore': [ @@ -153,10 +153,10 @@ def test_parse_default_ignore(i, s): return TEST_PARSE_DEFAULT_IGNORE.format(i=i, d=d, s=s) -def test_fuzzy(i, s): +def test_fuzzy_tzinfo(i, s): d = parse(s, fuzzy=True) - return TEST_FUZZY.format(i=i, d=d, s=s) + return TEST_FUZZY_TZINFO.format(i=i, d=d, s=s, offset=int(d.tzinfo._offset.total_seconds())) # Here lies all the ugly junk. TEST_HEADER = ''' @@ -409,14 +409,14 @@ fn test_parse_default_ignore{i}() {{ Some(default_rsdate), false, HashMap::new()); }}\n''' -TEST_FUZZY = ''' +TEST_FUZZY_TZINFO = ''' #[test] fn test_fuzzy{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 + micros: {d.microsecond}, tzo: Some({offset}) }}; parse_fuzzy_and_assert(pdt, None, info, "{s}", None, None, true, false, None, false, HashMap::new()); diff --git a/src/lib.rs b/src/lib.rs index 7003a94..46266be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -718,7 +718,7 @@ impl Parser { } i += 1; - } else if !self.info.get_jump(&l[i]) || fuzzy { + } else if !(self.info.get_jump(&l[i]) || fuzzy) { return Err(ParseError::UnrecognizedToken(l[i].clone())); } else { skipped_idxs.push(i); diff --git a/tests/pycompat.rs b/tests/pycompat.rs index 319f714..7efe2d2 100644 --- a/tests/pycompat.rs +++ b/tests/pycompat.rs @@ -1740,7 +1740,7 @@ fn test_fuzzy0() { let pdt = PyDateTime { year: 2003, month: 9, day: 25, hour: 10, minute: 49, second: 41, - micros: 0, tzo: None + micros: 0, tzo: Some(-10800) }; parse_fuzzy_and_assert(pdt, None, info, "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", None, None, true, false, None, false, HashMap::new());