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


Python _strptime.TimeRE方法代码示例

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


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

示例1: test_TimeRE_recreation_timezone

# 需要导入模块: import _strptime [as 别名]
# 或者: from _strptime import TimeRE [as 别名]
def test_TimeRE_recreation_timezone(self):
        # The TimeRE instance should be recreated upon changing the timezone.
        oldtzname = time.tzname
        tm = _strptime._strptime_time(time.tzname[0], '%Z')
        self.assertEqual(tm.tm_isdst, 0)
        tm = _strptime._strptime_time(time.tzname[1], '%Z')
        self.assertEqual(tm.tm_isdst, 1)
        # Get id of current cache object.
        first_time_re = _strptime._TimeRE_cache
        # Change the timezone and force a recreation of the cache.
        os.environ['TZ'] = 'EST+05EDT,M3.2.0,M11.1.0'
        time.tzset()
        tm = _strptime._strptime_time(time.tzname[0], '%Z')
        self.assertEqual(tm.tm_isdst, 0)
        tm = _strptime._strptime_time(time.tzname[1], '%Z')
        self.assertEqual(tm.tm_isdst, 1)
        # Get the new cache object's id.
        second_time_re = _strptime._TimeRE_cache
        # They should not be equal.
        self.assertIsNot(first_time_re, second_time_re)
        # Make sure old names no longer accepted.
        with self.assertRaises(ValueError):
            _strptime._strptime_time(oldtzname[0], '%Z')
        with self.assertRaises(ValueError):
            _strptime._strptime_time(oldtzname[1], '%Z') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_strptime.py

示例2: setUp

# 需要导入模块: import _strptime [as 别名]
# 或者: from _strptime import TimeRE [as 别名]
def setUp(self):
        """Construct generic TimeRE object."""
        self.time_re = _strptime.TimeRE()
        self.locale_time = _strptime.LocaleTime() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_strptime.py

示例3: test_pattern

# 需要导入模块: import _strptime [as 别名]
# 或者: from _strptime import TimeRE [as 别名]
def test_pattern(self):
        # Test TimeRE.pattern
        pattern_string = self.time_re.pattern(r"%a %A %d")
        self.assertTrue(pattern_string.find(self.locale_time.a_weekday[2]) != -1,
                        "did not find abbreviated weekday in pattern string '%s'" %
                         pattern_string)
        self.assertTrue(pattern_string.find(self.locale_time.f_weekday[4]) != -1,
                        "did not find full weekday in pattern string '%s'" %
                         pattern_string)
        self.assertTrue(pattern_string.find(self.time_re['d']) != -1,
                        "did not find 'd' directive pattern string '%s'" %
                         pattern_string) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_strptime.py

示例4: test_blankpattern

# 需要导入模块: import _strptime [as 别名]
# 或者: from _strptime import TimeRE [as 别名]
def test_blankpattern(self):
        # Make sure when tuple or something has no values no regex is generated.
        # Fixes bug #661354
        test_locale = _strptime.LocaleTime()
        test_locale.timezone = (frozenset(), frozenset())
        self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '',
                         "with timezone == ('',''), TimeRE().pattern('%Z') != ''") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_strptime.py

示例5: test_locale_data_w_regex_metacharacters

# 需要导入模块: import _strptime [as 别名]
# 或者: from _strptime import TimeRE [as 别名]
def test_locale_data_w_regex_metacharacters(self):
        # Check that if locale data contains regex metacharacters they are
        # escaped properly.
        # Discovered by bug #1039270 .
        locale_time = _strptime.LocaleTime()
        locale_time.timezone = (frozenset(("utc", "gmt",
                                            "Tokyo (standard time)")),
                                frozenset("Tokyo (daylight time)"))
        time_re = _strptime.TimeRE(locale_time)
        self.assertTrue(time_re.compile("%Z").match("Tokyo (standard time)"),
                        "locale data that contains regex metacharacters is not"
                        " properly escaped") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_strptime.py

示例6: test_new_localetime

# 需要导入模块: import _strptime [as 别名]
# 或者: from _strptime import TimeRE [as 别名]
def test_new_localetime(self):
        # A new LocaleTime instance should be created when a new TimeRE object
        # is created.
        locale_time_id = _strptime._TimeRE_cache.locale_time
        _strptime._TimeRE_cache.locale_time.lang = "Ni"
        _strptime._strptime_time("10", "%d")
        self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_strptime.py


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