mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
Make python version of fromtimestamp behave more like C.
This commit is contained in:
parent
0f0c3320ee
commit
aeb039863d
2 changed files with 20 additions and 10 deletions
|
@ -1728,9 +1728,15 @@ class TestDateTime(TestDate):
|
|||
|
||||
def test_microsecond_rounding(self):
|
||||
# Test whether fromtimestamp "rounds up" floats that are less
|
||||
# than one microsecond smaller than an integer.
|
||||
# than 1/2 microsecond smaller than an integer.
|
||||
self.assertEqual(self.theclass.fromtimestamp(0.9999999),
|
||||
self.theclass.fromtimestamp(1))
|
||||
self.assertEqual(self.theclass.fromtimestamp(0.99999949).microsecond,
|
||||
999999)
|
||||
# XXX Arguably incorrect behavior. Since round(0.6112295, 6)
|
||||
# returns 0.611229, we should see 611229 us below, not 611230
|
||||
self.assertEqual(self.theclass.fromtimestamp(0.6112295).microsecond,
|
||||
611230)
|
||||
|
||||
def test_insane_fromtimestamp(self):
|
||||
# It's possible that some platform maps time_t to double,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue