spotfiresoftware / spotfire-python

Package for Building Python Extensions to Spotfire®
Other
18 stars 6 forks source link

Fix unit test DataFunctionTest.test_tz_aware_datetime failure under random conditions #52

Closed bbassett-tibco closed 9 months ago

bbassett-tibco commented 1 year ago

It appears that during a recent workflow run, the DataFunctionTest.test_tz_aware_datetime unit test encountered a failure that appears to be the result of a rounding error during the truncation of microseconds to the SBDF format's millisecond resolution:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\spotfire\test\test_sbdf.py", line 436, in test_tz_aware_datetime
    self.assertEqual(val, now_roundtrip, f"df2[{col}] = {repr(val)}")
AssertionError: datetime.datetime(2023, 9, 8, 1, 51, 46, 382000) != datetime.datetime(2023, 9, 8, 1, 51, 46, 381000) : df2[naive] = datetime.datetime(2023, 9, 8, 1, 51, 46, 382000)

Note that the first value in the assertion (382000 us) is the value read back from the SBDF round trip, while the second value (381000 us) is the calculated value that is expected to be returned to Python from the SBDF file.

bbassett-tibco commented 9 months ago

Rewrote the test to allow up to a millisecond difference.