Skip to content

Commit

Permalink
Fixed tests that compared a stable time with a ten year old Expires h…
Browse files Browse the repository at this point in the history
…andler.

Fixes #127
  • Loading branch information
mauritsvanrees committed Jun 2, 2023
1 parent fe92116 commit 53836bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions news/127.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed tests that compared a stable time with a ten year old Expires handler.
[maurits]
10 changes: 8 additions & 2 deletions plone/app/caching/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from Acquisition import Explicit
from datetime import date
from datetime import datetime
from datetime import timedelta
from plone.app.caching.interfaces import IPloneCacheSettings
from plone.app.caching.utils import getObjectDefaultView
from plone.app.caching.utils import isPurged
Expand All @@ -25,9 +26,14 @@


def stable_now():
"""Patch localized_now to allow stable results in tests."""
"""Patch localized_now to allow stable results in tests.
Note that a fixed date is not good enough:
several tests compare this date with an Expires header,
and this header may be set to ten years ago.
"""
tzinfo = pytz.timezone(TEST_TIMEZONE)
now = datetime(2013, 6, 5, 10, 0, 0).replace(microsecond=0)
now = datetime.now() - timedelta(days=1000)
now = tzinfo.localize(now) # set tzinfo with correct DST offset
return now

Expand Down

0 comments on commit 53836bd

Please sign in to comment.