Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail after 2022-05-14 #255

Closed
bmwiedemann opened this issue Jun 29, 2021 · 7 comments
Closed

Tests fail after 2022-05-14 #255

bmwiedemann opened this issue Jun 29, 2021 · 7 comments

Comments

@bmwiedemann
Copy link

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 ============
@seperman
Copy link
Owner

Hi @bmwiedemann
Haha, interesting. I wonder why this is happening. Does that have to do with a leap year? I can use something like Python "freezetime" to change the current time to the future and see what happens.

@bmwiedemann
Copy link
Author

2022 is no leap year. Maybe some part of the code uses 365 as number of days in a year, when in reality it is closer to 365.2425

@bmwiedemann
Copy link
Author

The problem is still there with current deepdiff-5.6.0 - is there a chance to get a fix in the next 4 months or should we just disable the test?

@seperman
Copy link
Owner

seperman commented Jan 10, 2022 via email

@bmwiedemann
Copy link
Author

only 6 weeks left...

@seperman
Copy link
Owner

Ok fixing it now. Thanks for the reminder!

@seperman seperman mentioned this issue Apr 10, 2022
7 tasks
@seperman
Copy link
Owner

@bmwiedemann DeepDiff 5.8.0 is published and this issues is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants