New submission from Hildo Guillardi Júnior <hildo...@gmail.com>:

I am running a test

`self.assertAlmostEqual(date1, date2, 6)`

and getting the result:

ERROR: test_datetime_linspace (__main__.TestFunctions)
Check the linspace object output type and delta between them.
----------------------------------------------------------------------
Traceback (most recent call last):
  File 
"/home/lab/Documents/UNICAMP/LabREI/web-visualization/tests/test_interpreter.py",
 line 87, in test_datetime_linspace
    self.assertAlmostEqual(time_list[-1], now, 6)
  File "/usr/lib/python3.8/unittest/case.py", line 957, in assertAlmostEqual
    if round(diff, places) == 0:
TypeError: type datetime.timedelta doesn't define __round__ method


Despite the definition

@overload
    def assertAlmostEqual(self, first: datetime.datetime, second: 
datetime.datetime,
                          places: int = ..., msg: Any = ...,
                          delta: datetime.timedelta = ...) -> None: ...

on file case.pyi, the case.py doesn't deal good with `if round(diff, places) == 
0:`, with `diff` the difference between the two varaibles.

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 376904
nosy: hildogjr
priority: normal
severity: normal
status: open
title: Unittest do not support datatime for AlmostEqual method
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41785>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to