Python _strptime.TimeRE() Examples
The following are 30
code examples of _strptime.TimeRE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_strptime
, or try the search function
.
Example #1
Source File: test_strptime.py From ironpython2 with Apache License 2.0 | 6 votes |
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')
Example #2
Source File: test_strptime.py From ironpython3 with Apache License 2.0 | 6 votes |
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')
Example #3
Source File: test_strptime.py From android_universal with MIT License | 6 votes |
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')
Example #4
Source File: test_strptime.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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')
Example #5
Source File: test_strptime.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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")
Example #6
Source File: test_strptime.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def setUp(self): """Construct generic TimeRE object.""" self.time_re = _strptime.TimeRE() self.locale_time = _strptime.LocaleTime()
Example #7
Source File: test_strptime.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_new_localetime(self): # A new LocaleTime instance should be created when a new TimeRE object # is created. locale_time_id = id(_strptime._TimeRE_cache.locale_time) _strptime._TimeRE_cache.locale_time.lang = "Ni" _strptime.strptime("10", "%d") self.failIfEqual(locale_time_id, id(_strptime._TimeRE_cache.locale_time))
Example #8
Source File: test_strptime.py From medicare-demo with Apache License 2.0 | 5 votes |
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.failUnless(time_re.compile("%Z").match("Tokyo (standard time)"), "locale data that contains regex metacharacters is not" " properly escaped")
Example #9
Source File: test_strptime.py From medicare-demo with Apache License 2.0 | 5 votes |
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.failUnless(_strptime.TimeRE(test_locale).pattern("%Z") == '', "with timezone == ('',''), TimeRE().pattern('%Z') != ''")
Example #10
Source File: test_strptime.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_pattern(self): # Test TimeRE.pattern pattern_string = self.time_re.pattern(r"%a %A %d") self.failUnless(pattern_string.find(self.locale_time.a_weekday[2]) != -1, "did not find abbreviated weekday in pattern string '%s'" % pattern_string) self.failUnless(pattern_string.find(self.locale_time.f_weekday[4]) != -1, "did not find full weekday in pattern string '%s'" % pattern_string) self.failUnless(pattern_string.find(self.time_re['d']) != -1, "did not find 'd' directive pattern string '%s'" % pattern_string)
Example #11
Source File: test_strptime.py From medicare-demo with Apache License 2.0 | 5 votes |
def setUp(self): """Construct generic TimeRE object.""" self.time_re = _strptime.TimeRE() self.locale_time = _strptime.LocaleTime()
Example #12
Source File: test_strptime.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: test_strptime.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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') != ''")
Example #14
Source File: test_strptime.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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') != ''")
Example #15
Source File: test_strptime.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: test_strptime.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def setUp(self): """Construct generic TimeRE object.""" self.time_re = _strptime.TimeRE() self.locale_time = _strptime.LocaleTime()
Example #17
Source File: test_strptime.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #18
Source File: test_strptime.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #19
Source File: test_strptime.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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') != ''")
Example #20
Source File: test_strptime.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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")
Example #21
Source File: test_strptime.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #22
Source File: test_strptime.py From android_universal with MIT License | 5 votes |
def setUp(self): """Construct generic TimeRE object.""" self.time_re = _strptime.TimeRE() self.locale_time = _strptime.LocaleTime()
Example #23
Source File: test_strptime.py From android_universal with MIT License | 5 votes |
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)
Example #24
Source File: test_strptime.py From android_universal with MIT License | 5 votes |
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') != ''")
Example #25
Source File: test_strptime.py From android_universal with MIT License | 5 votes |
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")
Example #26
Source File: test_strptime.py From android_universal with MIT License | 5 votes |
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)
Example #27
Source File: test_strptime.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def setUp(self): """Construct generic TimeRE object.""" self.time_re = _strptime.TimeRE() self.locale_time = _strptime.LocaleTime()
Example #28
Source File: test_strptime.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #29
Source File: test_strptime.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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') != ''")
Example #30
Source File: test_strptime.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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")