Skip to content
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

Bad test case in TestComplexDateTimes #141

Closed
codereverser opened this issue Nov 6, 2015 · 6 comments
Closed

Bad test case in TestComplexDateTimes #141

codereverser opened this issue Nov 6, 2015 · 6 comments

Comments

@codereverser
Copy link

File : TestComplexDateTimes.py - Function : testDate3ConfusedHourAndYear

        self.assertExpectedResult(
            self.cal.parse('December 30th 23:02', start),
            (datetime.datetime(self.yr
                               if (self.mth < 12 and
                                   self.dy < 30 and
                                   self.hr < 23 and
                                   self.mn < 2)
                               else self.yr + 1,
                               12, 30, 23, 2, 0).timetuple(), 3))

The check for self.yr + 1 doesn't seem right. It always fails if self.mn > 2, irrespective of the current date.
PS:- There are a couple more similar bad tests in the same function.

@philiptzou
Copy link
Collaborator

Hmm I think it's because some flag control the auto-complicated year if the
date is larger/smaller than current date. So this is a small trick to get
over of the side effect of it.
codereverser notifications@github.com于2015年11月5日 周四19:08写道:

File : TestComplexDateTimes.py - Function : testDate3ConfusedHourAndYear

    self.assertExpectedResult(
        self.cal.parse('December 30th 23:02', start),
        (datetime.datetime(self.yr
                           if (self.mth < 12 and
                               self.dy < 30 and
                               self.hr < 23 and
                               self.mn < 2)
                           else self.yr + 1,
                           12, 30, 23, 2, 0).timetuple(), 3))

The check for self.yr + 1 doesn't seem right. It always fails if self.mn

2, irrespective of the current date.
PS:- There are a couple more similar bad tests in the same function.


Reply to this email directly or view it on GitHub
#141.

@bear
Copy link
Owner

bear commented Nov 6, 2015

I was curious about that myself the other night. Did the switch to contexts or my merge for Python v3 break something?

@codereverser
Copy link
Author

I don't think so. The tests are failing because the check to compare two dates is not correct. i.e.

(self.mth < 12 and
self.dy < 30 and
self.hr < 23 and
self.mn < 2)

always fails if say, self.dy = 31 or self.mn = 10 regardless of other values (where technically it should fail only during Dec 30 23:03 - 23:59).

I think it should've been something like

datetime.datetime(self.yr, self.mth, self.dy, self.hr, self.mn) <= datetime.datetime(self.yr, 12, 30, 23, 2)

@bear
Copy link
Owner

bear commented Nov 6, 2015

please do create a pull request with what you feel it should be so we can fix this

@philiptzou
Copy link
Collaborator

Well I get what you are saying for... Yes I made a stupid logic mistake here. Also be fixed in #142.

@codereverser
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants