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

Invalid on windows timezone test #2452

Closed
bpoldrack opened this issue Apr 26, 2018 · 0 comments · Fixed by #4306
Closed

Invalid on windows timezone test #2452

bpoldrack opened this issue Apr 26, 2018 · 0 comments · Fixed by #4306
Labels
platform-windows Issue concerned with Windows

Comments

@bpoldrack
Copy link
Member

What is the problem?

In https://ci.appveyor.com/project/mih/datalad/build/1.0.20 the following test is failing, since time.tzset() is available on Unix only.

However, I don't quite get its purpose in the test in question:

def test_get_timestamp_suffix():
    # we need to patch temporarily TZ
    import time
    try:
        with patch.dict('os.environ', {'TZ': 'GMT'}):
            time.tzset()
            # skynet DOB
            assert_equal(get_timestamp_suffix(0), '-1970-01-01T00:00:00+0000')
            assert_equal(get_timestamp_suffix(0, prefix="+"),
                         '+1970-01-01T00:00:00+0000')
            # yoh found no way to mock things out and didn't want to provide
            # explicit call to anything to get current time with the timezone,
            # so disabling this test for now besides that it should return smth
            # sensible ;)
            #with patch.object(time, 'localtime', lambda: 1):
            #    assert_equal(get_timestamp_suffix(),
            #  '-1970-01-01T00:00:01+0000')  # skynet is 1 sec old
            assert(get_timestamp_suffix().startswith('-'))
    finally:
        time.tzset()

But timestamp 0 should always resolve to this very string. At the end of the day this is just calling time.gmtime(0), the result of which should be independent on local TZ, no? Do I miss something here, @yarikoptic ?
If I'm right, the use of time.tzset() is simply superfluous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-windows Issue concerned with Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants