-
Notifications
You must be signed in to change notification settings - Fork 523
add day check; with test; closes #360 #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
LGTM. |
dateutil/parser.py
Outdated
| return 1 <= value <= 31 | ||
| elif not self.has_year: | ||
| # Be permissive, assume leapyear | ||
| return 1 <= value <= monthrange(2000, self.month)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird choice of an exemplary leap year, since this is one of the weird leap years.
Is it meaningful to add a test that will hit this branch for leap and non-leap years?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I'm happy to use 1996.
Is it meaningful to add a test that will hit this branch for leap and non-leap years?
My expectation is that this will turn out to be fragile in ways unrelated to leap vs non-leap. My preference would be to keep an eye out for from-the-wild cases that hit these branches rather than try to concoct them for the sake of coverage stats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, I do have a couple of PRs coming up that are just adding tests, many of which will currently be xfails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think 1996 vs 2000 matters. Just gave me a start because I was like, "Wait, that's not supposed to be a leap year because it's a century, actually, wait, the century is divisible by 4..." Doesn't matter to a computer and the comment is necessary to make it clear why you chose 2000 anyway.
Regarding the tests, I think it might be a good idea to come up with some tests that will hit those branches. I can do it if you didn't have anything in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for it. Anything you don't get covered I'll circle back to get next week.
|
Hm.. I'm noticing there's not a codecov hook anymore, but actually this seems to be introducing some uncovered lines see here. @jbrockmendel Do you think you can come up with some strings that will hit those other cases? |
|
I haven't brainstormed any particularly good examples for the other cases. Got any in mind? |
|
I couldn't think of anything so I tried fuzzing the parser a bit with >>> from dateutil.parser import parse
>>> parse('02:17NOV2017CE')
...
AttributeError: '_ymd' has no attribute 'month' |
|
Good catch. I'll have to take a look at that fuzzer. Pushing a fix shortly. Though the trailing "BCE" is a whole other can of worms. |
|
It also works with a trailing |
|
Yah, I'm running the fuzzer now to get a feel for how it works. I vote for closing out this bug fix and not cargo-culting coverage. |
|
@jbrockmendel I wouldn't worry too much about the fuzzing, but I think that my insistence on coverage was not at all cargo culting, since in this case the code you've written is fundamentally broken. Anything that reaches the uncovered branches will fail with Worst case scenario, we can add tests that directly call |
Fair point. (Huh. The fix I pushed isn't showing up here... gotta see where that ended up)
I have no such reasoning, and I like the idea of using fuzzing to try to find them. All I'm getting at is that if we can't find such cases after [whatever the appropriate amount of effort is] we shouldn't let that stop us from fixing the bug we know about. |
|
I like this approach with |
Will evidently need rebasing after review.