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

IsoDateTimeFromToRangeFilterTests fail with DST #1050

Open
bmwiedemann opened this issue Mar 5, 2019 · 8 comments
Open

IsoDateTimeFromToRangeFilterTests fail with DST #1050

bmwiedemann opened this issue Mar 5, 2019 · 8 comments

Comments

@bmwiedemann
Copy link

One test starts to fail 2019-03-10 08:00 UTC
This coincides with a US DST 2019-03-10 02:00 (-0600)
test works again after end of DST ~ 2019-11-04

======================================================================
FAIL: test_filtering (tests.test_filtering.IsoDateTimeFromToRangeFilterTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/abuild/rpmbuild/BUILD/django-filter-2.1.0/tests/test_filtering.py", line 1005, in test_filtering
    self.assertEqual(len(results.qs), 2)
AssertionError: 1 != 2

----------------------------------------------------------------------
Ran 487 tests in 0.981s

FAILED (failures=1, skipped=14, expected failures=3)

This bug was found while working on reproducible builds for openSUSE.

@bmwiedemann bmwiedemann changed the title IsoDateTimeToRangeFilterTests fail with DST IsoDateTimeFromToRangeFilterTests fail with DST Mar 5, 2019
@carltongibson
Copy link
Owner

So is this a DST issue? Will it re-occur every year? (Can you propose a fix? 😉)

@bmwiedemann
Copy link
Author

Yes, it is a DST issue and it re-occurs every year. I looked at the code, but since I'm not a python expert and relevant code is distributed across multiple files and classes, it was not easy to see where the problem comes from. Maybe pdb could show things...

@carltongibson
Copy link
Owner

OK, thanks for the report. I will have a play at some point.

@carltongibson
Copy link
Owner

OK, so this just showed up here: https://travis-ci.org/carltongibson/django-filter/builds/514228812
Happily take a PR. If not I'll look at it at DjangoCon Europe sprints.

@lbazan
Copy link

lbazan commented Aug 16, 2019

  • /usr/bin/python3 runtests.py
    Creating test database for alias 'default'...
    System check identified no issues (0 silenced).
    .......sssssss...................................................................................................s..x...u....ss..x..x...................................................................................................................................................................................................................................s....................sss.........................................................................................................

Ran 489 tests in 1.354s

FAILED (skipped=14, expected failures=3, unexpected successes=1)
Destroying test database for alias 'default'...

  • exit 0

@carltongibson
Copy link
Owner

We'll need to revisit this after #1463.

Look into rewriting the test using @adamchainz's time-machine project

@carltongibson carltongibson pinned this issue Dec 16, 2021
@adamchainz
Copy link
Contributor

I think you could just decorate the test with:

@time_machine.travel(dt.datetime(2019, 3, 10, 7))

or similar, and the test will always run outside of DST.

@carltongibson
Copy link
Owner

That’s what I’m looking for. 😄

@carltongibson carltongibson unpinned this issue Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants