Skip to content

Tests fail after 2022-05-14 #255

@bmwiedemann

Description

@bmwiedemann

Describe the bug
TestDeepDistance.test_get_numeric_types_distance fails after 2022-05-14 10:00 UTC

To Reproduce
Build with a date after 2022-05-14, e.g. in Debian or openSUSE do

osc co openSUSE:Factory/python-deepdiff && cd $_
osc build --vm-type=kvm --noservice --clean --build-opt=--vm-custom-opt="-rtc base=2022-05-15T00:00:00"

Expected behavior
Tests should keep passing for at least 20 years, if possible.

OS, DeepDiff version and Python version (please complete the following information):

  • deepdiff-5.2.3-gh
  • OS: openSUSE-Tumbleweed
  • Version 20210626

Additional context
As part of my work on reproducible builds for openSUSE, I check that software still gives identical build results in the future.
The usual offset is +15 years, because that is how long I expect some software will be used in some places.
This showed up failing tests in our package build.
See https://reproducible-builds.org/ for why this matters.

 =================================== FAILURES ===================================
 _ TestDeepDistance.test_get_numeric_types_distance[num11-num21-1-0.002707370659621624] _
 
 self = <tests.test_distance.TestDeepDistance object at 0x7fe8c90cba60>
 num1 = datetime.datetime(2036, 7, 3, 4, 17, 5, 150486) 
 num2 = datetime.datetime(2036, 10, 11, 4, 17, 5, 150496), max_ = 1
 expected = 0.002707370659621624
 
     @pytest.mark.parametrize('num1, num2, max_, expected', [
         (10, -10.1, .3, 0.3),
         (datetime.datetime.utcnow(), datetime.datetime.utcnow() + datetime.timedelta(days=100), 1, 0.002707370659621624),
         (1589703146.9556487, 1001589703146.9557, 1, 0.9968306702929068),
         (datetime.time(10, 11), datetime.time(12, 11), .5, 0.0447093889716),
         (datetime.timedelta(days=2), datetime.timedelta(12, 11), .5, 0.35714415626180646),
         (datetime.date(2018, 1, 1), datetime.date(2020, 1, 10), 1, 0.0005013129787148886),
     ])
     def test_get_numeric_types_distance(self, num1, num2, max_, expected):
         result = get_numeric_types_distance(num1, num2, max_)
 >       assert abs(expected - result) < 0.0001
 E       assert 0.0006531540097863232 < 0.0001
 E        +  where 0.0006531540097863232 = abs((0.002707370659621624 - 0.002054216649835301))
 
 tests/test_distance.py:220: AssertionError
 =========================== short test summary info ============================
 FAILED tests/test_distance.py::TestDeepDistance::test_get_numeric_types_distance[num11-num21-1-0.002707370659621624]
 ============ 1 failed, 594 passed, 6 skipped, 8 deselected in 6.50s ============

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions