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

Fixed time zone issue in tests #11

Merged
merged 1 commit into from Feb 26, 2014
Merged

Fixed time zone issue in tests #11

merged 1 commit into from Feb 26, 2014

Conversation

mxjeff
Copy link

@mxjeff mxjeff commented Feb 26, 2014

Use of datetime's fromtimestamp method in test_cache_request_unfresh_max_age is a problem since it honors local time zone. Then the http Date header forged is not UTC/GMT.
It makes this particular test fail for positive UTC offset time zone such as mine (France UTC+0100 winter time).

I also switched to time only and drop all datetime method as it is sometime confusing because of its naive/aware timezone property.

Also add GMT tag in TIME_FMT :
http://tools.ietf.org/html/rfc2616#section-3.3

Use of datetime's fromtimestamp method in test_cache_request_unfresh_max_ageis a problem since it honors local time zone.
Then the http Date header forged is not UTC/GMT.
It makes this particular test fail for positive UTC offset time zone
such as mine (France UTC+0100 winter time).

I also switched to time only and drop all datetime method as it
is sometime confusing because of its naive/aware timezone property.

Also add GMT tag in TIME_FMT :
    http://tools.ietf.org/html/rfc2616#section-3.3
@mxjeff
Copy link
Author

mxjeff commented Feb 26, 2014

Please try to reproduce the issue before merging in order to validate my understanding of the problem.

Setting your time zone to something positive (ie. east of UTC such as France/Paris) should trigger it if I'm right.

now = datetime.datetime.fromtimestamp(earlier).strftime(TIME_FMT)

earlier = time.time() - 3700 # epoch - 1h01m40s
now = time.strftime(TIME_FMT, time.gmtime(earlier))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useful part is here, I decided then to remove all datetime references but this is not necessary, only a matter of taste because I believe its naive/aware approach of TZ is confusing.

ionrock added a commit that referenced this pull request Feb 26, 2014
Fixed time zone issue in tests
@ionrock ionrock merged commit 3298adc into psf:master Feb 26, 2014
@ionrock
Copy link
Contributor

ionrock commented Feb 26, 2014

@mxjeff Great work! You make an excellent point regarding timezones. That is another good question to discuss in the docs.

@mxjeff mxjeff deleted the test.tz.issue branch March 11, 2014 09:10
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.

None yet

2 participants