Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 10 commits into from
May 4, 2015
Merged

Add tests for times module #41

merged 10 commits into from
May 4, 2015

Conversation

tiwilliam
Copy link
Contributor

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.

@tiwilliam
Copy link
Contributor Author

Apparently fails on Travis but works on my Mac, will take a look.

@tiwilliam
Copy link
Contributor Author

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])
Copy link
Member

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.

Copy link
Contributor Author

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.

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)
Copy link
Member

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?

Copy link
Contributor Author

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.

@tiwilliam
Copy link
Contributor Author

Alright @methane, localtime tests are now mocked and works no matter timezone.

methane added a commit that referenced this pull request May 4, 2015
@methane methane merged commit c528f50 into PyMySQL:master May 4, 2015
@methane
Copy link
Member

methane commented May 4, 2015

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

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.