-
Notifications
You must be signed in to change notification settings - Fork 443
Add tests for times module #41
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
Apparently fails on Travis but works on my Mac, will take a look. |
This PR will also switch from nose to py.test, simply because it's much easier to debug failing test. And my ambition is to increase test coverage. I've also added a coverage report. |
@@ -18,15 +18,15 @@ | ||
|
||
def DateFromTicks(ticks): | ||
"""Convert UNIX ticks into a date instance.""" | ||
return date(*localtime(ticks)[:3]) | ||
return date(*gmtime(ticks)[:3]) |
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 want to change behavior from MySQL-python.
Please keep using localtime.
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 understand, just didn't make sense to have these return local timezone. I've reverted the commit.
This reverts commit 8efd1d8.
class TestTicks(unittest.TestCase): | ||
def test_date_from_ticks(self): | ||
assert times.DateFromTicks(0) == date(1970, 1, 1) | ||
assert times.DateFromTicks(1430000000) == date(2015, 4, 25) |
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.
Do these tests depends on time offset of machine?
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.
Yes, as of last revert, not sure how to mock these.
Alright @methane, localtime tests are now mocked and works no matter timezone. |
Thanks! |
This adds close to 100% coverage for
MySQLdb.times
. We're experience a lot of our request time spent in this module and this is the first step of trying to optimize its performance.