当前位置: 首页>>代码示例>>Python>>正文


Python dateutil.__version__方法代码示例

本文整理汇总了Python中dateutil.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python dateutil.__version__方法的具体用法?Python dateutil.__version__怎么用?Python dateutil.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dateutil的用法示例。


在下文中一共展示了dateutil.__version__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fallback_plural

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_fallback_plural(self):
        # test moving from daylight savings to standard time
        import dateutil
        for tz, utc_offsets in self.timezone_utc_offsets.items():
            hrs_pre = utc_offsets['utc_offset_daylight']
            hrs_post = utc_offsets['utc_offset_standard']

            if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
                # buggy ambiguous behavior in 2.6.0
                # GH 14621
                # https://github.com/dateutil/dateutil/issues/321
                self._test_all_offsets(
                    n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
                                                     hrs_pre, tz),
                    expected_utc_offset=hrs_post)
            elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
                # fixed, but skip the test
                continue 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_offsets.py

示例2: test_version_info

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_version_info(selenium):
    from distutils.version import LooseVersion

    version_py_str = selenium.run(
        """
            import pyodide

            pyodide.__version__
            """
    )
    version_py = LooseVersion(version_py_str)
    assert version_py > LooseVersion("0.0.1")

    version_js_str = selenium.run_js("return pyodide.version()")
    version_js = LooseVersion(version_js_str)
    assert version_py == version_js 
开发者ID:iodide-project,项目名称:pyodide,代码行数:18,代码来源:test_python.py

示例3: testImportRoot

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def testImportRoot(self):
        import dateutil

        self.assertTrue(hasattr(dateutil, '__version__')) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:6,代码来源:test_imports.py

示例4: test_dti_construction_ambiguous_endpoint

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_dti_construction_ambiguous_endpoint(self, tz):
        # construction with an ambiguous end-point
        # GH#11626

        # FIXME: This next block fails to raise; it was taken from an older
        # version of this test that had an indention mistake that caused it
        # to not get executed.
        # with pytest.raises(pytz.AmbiguousTimeError):
        #    date_range("2013-10-26 23:00", "2013-10-27 01:00",
        #               tz="Europe/London", freq="H")

        times = date_range("2013-10-26 23:00", "2013-10-27 01:00", freq="H",
                           tz=tz, ambiguous='infer')
        assert times[0] == Timestamp('2013-10-26 23:00', tz=tz, freq="H")

        if str(tz).startswith('dateutil'):
            if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
                # see GH#14621
                assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
                                              tz=tz, freq="H")
            elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
                # fixed ambiguous behavior
                assert times[-1] == Timestamp('2013-10-27 01:00:00+0100',
                                              tz=tz, freq="H")
        else:
            assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
                                          tz=tz, freq="H") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:29,代码来源:test_timezones.py

示例5: test_tz_localize_ambiguous_compat

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_tz_localize_ambiguous_compat(self):
        # validate that pytz and dateutil are compat for dst
        # when the transition happens
        naive = Timestamp('2013-10-27 01:00:00')

        pytz_zone = 'Europe/London'
        dateutil_zone = 'dateutil/Europe/London'
        result_pytz = naive.tz_localize(pytz_zone, ambiguous=0)
        result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=0)
        assert result_pytz.value == result_dateutil.value
        assert result_pytz.value == 1382835600000000000

        if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
            # dateutil 2.6 buggy w.r.t. ambiguous=0
            # see gh-14621
            # see https://github.com/dateutil/dateutil/issues/321
            assert (result_pytz.to_pydatetime().tzname() ==
                    result_dateutil.to_pydatetime().tzname())
            assert str(result_pytz) == str(result_dateutil)
        elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
            # fixed ambiguous behavior
            assert result_pytz.to_pydatetime().tzname() == 'GMT'
            assert result_dateutil.to_pydatetime().tzname() == 'BST'
            assert str(result_pytz) != str(result_dateutil)

        # 1 hour difference
        result_pytz = naive.tz_localize(pytz_zone, ambiguous=1)
        result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=1)
        assert result_pytz.value == result_dateutil.value
        assert result_pytz.value == 1382832000000000000

        # dateutil < 2.6 is buggy w.r.t. ambiguous timezones
        if LooseVersion(dateutil.__version__) > LooseVersion('2.5.3'):
            # see gh-14621
            assert str(result_pytz) == str(result_dateutil)
            assert (result_pytz.to_pydatetime().tzname() ==
                    result_dateutil.to_pydatetime().tzname()) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:39,代码来源:test_timezones.py

示例6: test_yy_format_with_yearfirst

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_yy_format_with_yearfirst(self):
        data = """date,time,B,C
090131,0010,1,2
090228,1020,3,4
090331,0830,5,6
"""

        # See gh-217
        import dateutil
        if LooseVersion(dateutil.__version__) >= LooseVersion('2.5.0'):
            pytest.skip("testing yearfirst=True not-support"
                        "on datetutil < 2.5.0 this works but"
                        "is wrong")

        rs = self.read_csv(StringIO(data), index_col=0,
                           parse_dates=[['date', 'time']])
        idx = DatetimeIndex([datetime(2009, 1, 31, 0, 10, 0),
                             datetime(2009, 2, 28, 10, 20, 0),
                             datetime(2009, 3, 31, 8, 30, 0)],
                            dtype=object, name='date_time')
        xp = DataFrame({'B': [1, 3, 5], 'C': [2, 4, 6]}, idx)
        tm.assert_frame_equal(rs, xp)

        rs = self.read_csv(StringIO(data), index_col=0,
                           parse_dates=[[0, 1]])
        idx = DatetimeIndex([datetime(2009, 1, 31, 0, 10, 0),
                             datetime(2009, 2, 28, 10, 20, 0),
                             datetime(2009, 3, 31, 8, 30, 0)],
                            dtype=object, name='date_time')
        xp = DataFrame({'B': [1, 3, 5], 'C': [2, 4, 6]}, idx)
        tm.assert_frame_equal(rs, xp) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:33,代码来源:parse_dates.py

示例7: test_runpythonasync_different_package_name

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_runpythonasync_different_package_name(selenium_standalone):
    output = selenium_standalone.run_async(
        """
        import dateutil
        dateutil.__version__
        """
    )
    assert isinstance(output, str) 
开发者ID:iodide-project,项目名称:pyodide,代码行数:10,代码来源:test_python.py

示例8: test_runwebworker_different_package_name

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_runwebworker_different_package_name(selenium_standalone):
    output = selenium_standalone.run_webworker(
        """
        import dateutil
        dateutil.__version__
        """
    )
    assert isinstance(output, str) 
开发者ID:iodide-project,项目名称:pyodide,代码行数:10,代码来源:test_webworker.py

示例9: test_ambiguous_compat

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_ambiguous_compat(self):
        # validate that pytz and dateutil are compat for dst
        # when the transition happens

        pytz_zone = 'Europe/London'
        dateutil_zone = 'dateutil/Europe/London'
        result_pytz = (Timestamp('2013-10-27 01:00:00')
                       .tz_localize(pytz_zone, ambiguous=0))
        result_dateutil = (Timestamp('2013-10-27 01:00:00')
                           .tz_localize(dateutil_zone, ambiguous=0))
        assert result_pytz.value == result_dateutil.value
        assert result_pytz.value == 1382835600000000000

        if dateutil.__version__ < LooseVersion('2.6.0'):
            # dateutil 2.6 buggy w.r.t. ambiguous=0
            # see gh-14621
            # see https://github.com/dateutil/dateutil/issues/321
            assert (result_pytz.to_pydatetime().tzname() ==
                    result_dateutil.to_pydatetime().tzname())
            assert str(result_pytz) == str(result_dateutil)
        elif dateutil.__version__ > LooseVersion('2.6.0'):
            # fixed ambiguous behavior
            assert result_pytz.to_pydatetime().tzname() == 'GMT'
            assert result_dateutil.to_pydatetime().tzname() == 'BST'
            assert str(result_pytz) != str(result_dateutil)

        # 1 hour difference
        result_pytz = (Timestamp('2013-10-27 01:00:00')
                       .tz_localize(pytz_zone, ambiguous=1))
        result_dateutil = (Timestamp('2013-10-27 01:00:00')
                           .tz_localize(dateutil_zone, ambiguous=1))
        assert result_pytz.value == result_dateutil.value
        assert result_pytz.value == 1382832000000000000

        # dateutil < 2.6 is buggy w.r.t. ambiguous timezones
        if dateutil.__version__ > LooseVersion('2.5.3'):
            # see gh-14621
            assert str(result_pytz) == str(result_dateutil)
            assert (result_pytz.to_pydatetime().tzname() ==
                    result_dateutil.to_pydatetime().tzname()) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:42,代码来源:test_timezones.py

示例10: test_yy_format_with_yearfirst

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_yy_format_with_yearfirst(self):
        data = """date,time,B,C
090131,0010,1,2
090228,1020,3,4
090331,0830,5,6
"""

        # See gh-217
        import dateutil
        if dateutil.__version__ >= LooseVersion('2.5.0'):
            pytest.skip("testing yearfirst=True not-support"
                        "on datetutil < 2.5.0 this works but"
                        "is wrong")

        rs = self.read_csv(StringIO(data), index_col=0,
                           parse_dates=[['date', 'time']])
        idx = DatetimeIndex([datetime(2009, 1, 31, 0, 10, 0),
                             datetime(2009, 2, 28, 10, 20, 0),
                             datetime(2009, 3, 31, 8, 30, 0)],
                            dtype=object, name='date_time')
        xp = DataFrame({'B': [1, 3, 5], 'C': [2, 4, 6]}, idx)
        tm.assert_frame_equal(rs, xp)

        rs = self.read_csv(StringIO(data), index_col=0,
                           parse_dates=[[0, 1]])
        idx = DatetimeIndex([datetime(2009, 1, 31, 0, 10, 0),
                             datetime(2009, 2, 28, 10, 20, 0),
                             datetime(2009, 3, 31, 8, 30, 0)],
                            dtype=object, name='date_time')
        xp = DataFrame({'B': [1, 3, 5], 'C': [2, 4, 6]}, idx)
        tm.assert_frame_equal(rs, xp) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:33,代码来源:parse_dates.py

示例11: test_repr

# 需要导入模块: import dateutil [as 别名]
# 或者: from dateutil import __version__ [as 别名]
def test_repr(self):
        dates = ['2014-03-07', '2014-01-01 09:00',
                 '2014-01-01 00:00:00.000000001']

        # dateutil zone change (only matters for repr)
        if (dateutil.__version__ >= LooseVersion('2.3') and
            (dateutil.__version__ <= LooseVersion('2.4.0') or
             dateutil.__version__ >= LooseVersion('2.6.0'))):
            timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern',
                         'dateutil/US/Pacific']
        else:
            timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern',
                         'dateutil/America/Los_Angeles']

        freqs = ['D', 'M', 'S', 'N']

        for date in dates:
            for tz in timezones:
                for freq in freqs:

                    # avoid to match with timezone name
                    freq_repr = "'{0}'".format(freq)
                    if tz.startswith('dateutil'):
                        tz_repr = tz.replace('dateutil', '')
                    else:
                        tz_repr = tz

                    date_only = Timestamp(date)
                    assert date in repr(date_only)
                    assert tz_repr not in repr(date_only)
                    assert freq_repr not in repr(date_only)
                    assert date_only == eval(repr(date_only))

                    date_tz = Timestamp(date, tz=tz)
                    assert date in repr(date_tz)
                    assert tz_repr in repr(date_tz)
                    assert freq_repr not in repr(date_tz)
                    assert date_tz == eval(repr(date_tz))

                    date_freq = Timestamp(date, freq=freq)
                    assert date in repr(date_freq)
                    assert tz_repr not in repr(date_freq)
                    assert freq_repr in repr(date_freq)
                    assert date_freq == eval(repr(date_freq))

                    date_tz_freq = Timestamp(date, tz=tz, freq=freq)
                    assert date in repr(date_tz_freq)
                    assert tz_repr in repr(date_tz_freq)
                    assert freq_repr in repr(date_tz_freq)
                    assert date_tz_freq == eval(repr(date_tz_freq))

        # This can cause the tz field to be populated, but it's redundant to
        # include this information in the date-string.
        date_with_utc_offset = Timestamp('2014-03-13 00:00:00-0400', tz=None)
        assert '2014-03-13 00:00:00-0400' in repr(date_with_utc_offset)
        assert 'tzoffset' not in repr(date_with_utc_offset)
        assert 'pytz.FixedOffset(-240)' in repr(date_with_utc_offset)
        expr = repr(date_with_utc_offset).replace("'pytz.FixedOffset(-240)'",
                                                  'pytz.FixedOffset(-240)')
        assert date_with_utc_offset == eval(expr) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:62,代码来源:test_timestamp.py


注:本文中的dateutil.__version__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。