Skip to content

Commit 4bb6d8a

Browse files
committed
tests: make test_apscheduler invariant to the TZ environment variable
Make `test_apscheduler` invariant to the `TZ` environment variable, by specifying the timezone when constructing `AsyncIOScheduler`. For the purposes of the test, the timezone itself should not matter, so use UTC. The `TZ` environment may contain values such as `UTC0` or `GMT+12`, which is valid but not supported by `tzlocal` that is used by `apscheduler` behind the scenes.
1 parent e6b8cf6 commit 4bb6d8a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/test_libraries.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ def tick():
108108
109109
110110
async def main():
111-
scheduler = AsyncIOScheduler()
111+
# Specify the timezone to use, to make the test invariant to TZ environment variable (which might be set
112+
# to UCT0 or GMT+12, which is valid but not supported by `tzlocal` that is used by `apscheduler` behind the
113+
# scenes.
114+
scheduler = AsyncIOScheduler(timezone=datetime.timezone.utc)
112115
scheduler.add_job(tick, "interval", seconds=1)
113116
scheduler.start()
114117

0 commit comments

Comments
 (0)