Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10575)

Side by Side Diff: Lib/test/test_time.py

Issue 8013: time.asctime segfaults when given a time in the far future
Patch Set: Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Modules/timemodule.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test import test_support 1 from test import test_support
2 import time 2 import time
3 import unittest 3 import unittest
4 4
5 5
6 class TimeTestCase(unittest.TestCase): 6 class TimeTestCase(unittest.TestCase):
7 7
8 def setUp(self): 8 def setUp(self):
9 self.t = time.time() 9 self.t = time.time()
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 strf_output = time.strftime(format, tt) 107 strf_output = time.strftime(format, tt)
108 try: 108 try:
109 time.strptime(strf_output, format) 109 time.strptime(strf_output, format)
110 except ValueError: 110 except ValueError:
111 self.fail("conversion specifier %r failed with '%s' input." % 111 self.fail("conversion specifier %r failed with '%s' input." %
112 (format, strf_output)) 112 (format, strf_output))
113 113
114 def test_asctime(self): 114 def test_asctime(self):
115 time.asctime(time.gmtime(self.t)) 115 time.asctime(time.gmtime(self.t))
116 self.assertRaises(TypeError, time.asctime, 0) 116 self.assertRaises(TypeError, time.asctime, 0)
117 self.assertRaises(TypeError, time.asctime, ())
118 self.assertRaises(ValueError, time.asctime,
119 (12345, 1, 0, 0, 0, 0, 0, 0, 0))
117 120
118 def test_tzset(self): 121 def test_tzset(self):
119 if not hasattr(time, "tzset"): 122 if not hasattr(time, "tzset"):
120 return # Can't test this; don't want the test suite to fail 123 return # Can't test this; don't want the test suite to fail
121 124
122 from os import environ 125 from os import environ
123 126
124 # Epoch time of midnight Dec 25th 2002. Never DST in northern 127 # Epoch time of midnight Dec 25th 2002. Never DST in northern
125 # hemisphere. 128 # hemisphere.
126 xmas2002 = 1040774400.0 129 xmas2002 = 1040774400.0
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 t0 = time.mktime(lt0) 215 t0 = time.mktime(lt0)
213 t1 = time.mktime(lt1) 216 t1 = time.mktime(lt1)
214 self.assertTrue(0 <= (t1-t0) < 0.2) 217 self.assertTrue(0 <= (t1-t0) < 0.2)
215 218
216 def test_main(): 219 def test_main():
217 test_support.run_unittest(TimeTestCase) 220 test_support.run_unittest(TimeTestCase)
218 221
219 222
220 if __name__ == "__main__": 223 if __name__ == "__main__":
221 test_main() 224 test_main()
OLDNEW
« no previous file with comments | « no previous file | Modules/timemodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+