[Ironpython-users] timedelta.total_seconds()

Cesar Mello cmello at gmail.com
Sat Mar 3 17:16:33 CET 2012


OK can someone please review?

https://github.com/cmello/IronLanguages-main/commit/0d9cad9e1ef203df6131b9d44013a0e0f31b8088


The test passes but I still don't know if/where to enable that test in the
build?

Thank you.

Best regards
Mello

On Sat, Mar 3, 2012 at 12:57 PM, Cesar Mello <cmello at gmail.com> wrote:

> I could run the test using the command line:
>
> D:\workspace-git\IronLanguages-main\Languages\IronPython\Internal>ipy
> ..\..\..\External.LCA_RESTRICTED\Languages\IronPython\27\Lib\test\test_datetime.py
>
> And then got 4 failures, including the one I want to fix:
>
> ======================================================================
> ERROR: test_total_seconds (__main__.TestTimeDelta)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File
> "..\..\..\External.LCA_RESTRICTED\Languages\IronPython\27\Lib\test\test_datetime.py",
> line 269, in test_total_seconds
>     self.assertEqual(td.total_seconds(), 31536000.0)
> AttributeError: 'timedelta' object has no attribute 'total_seconds'
>
> ======================================================================
>
>
> Just couldn't figure out yet how to run all the IronPython tests at once.
>
> Best regards
> Mello
>
> On Sat, Mar 3, 2012 at 12:08 PM, Cesar Mello <cmello at gmail.com> wrote:
>
>> Hi,
>>
>> Any help here is appreciated.
>>
>> I found a related unit test here:
>>
>>
>> main\External.LCA_RESTRICTED\Languages\IronPython\27\Lib\test\test_datetime.py:
>>
>>     def test_total_seconds(self):
>>         td = timedelta(days=365)
>>         self.assertEqual(td.total_seconds(), 31536000.0)
>>         for total_seconds in [123456.789012, -123456.789012, 0.123456, 0,
>> 1e6]:
>>             td = timedelta(seconds=total_seconds)
>>             self.assertEqual(td.total_seconds(), total_seconds)
>>         # Issue8644: Test that td.total_seconds() has the same
>>         # accuracy as td / timedelta(seconds=1).
>>         for ms in [-1, -2, -123]:
>>             td = timedelta(microseconds=ms)
>>             self.assertEqual(td.total_seconds(),
>>                              ((24*3600*td.days + td.seconds)*10**6
>>                               + td.microseconds)/10**6)
>>
>>
>> I would like to know how to enable and run this in the build.
>>
>> Thank you very much.
>>  Mello
>>
>>
>>
>>
>>
>> On Fri, Mar 2, 2012 at 2:10 PM, Jeff Hardy <jdhardy at gmail.com> wrote:
>>
>>> Just an oversight. Can you open an issue on ironpython.codeplex.com?
>>> Should be easy enough to get this in. If you're up to it, a pull
>>> request would be even better :)
>>>
>>> - Jeff
>>>
>>> On Fri, Mar 2, 2012 at 8:54 AM, Cesar Mello <cmello at gmail.com> wrote:
>>> > Hi!
>>> >
>>> > This method doesn't seem to be implemented. From
>>> > http://docs.python.org/library/datetime.html :
>>> > timedelta.total_seconds()
>>> >
>>> > Return the total number of seconds contained in the duration.
>>> Equivalent to
>>> > (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) /10**6
>>> > computed with true division enabled.
>>> >
>>> > Note that for very large time intervals (greater than 270 years on most
>>> > platforms) this method will lose microsecond accuracy.
>>> >
>>> > New in version 2.7.
>>> >
>>> >
>>> > Best regards!
>>> > Mello
>>> >
>>> > _______________________________________________
>>> > Ironpython-users mailing list
>>> > Ironpython-users at python.org
>>> > http://mail.python.org/mailman/listinfo/ironpython-users
>>> >
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120303/fc17eab0/attachment.html>


More information about the Ironpython-users mailing list