mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 13:37:17 +02:00
Fix #1234: use a mock datetime class to force UTC
This commit is contained in:
parent
f48e8e1fab
commit
e556c5e5d3
1 changed files with 11 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ Testing suite for contrib folder
|
|||
|
||||
"""
|
||||
|
||||
import datetime
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from mock import Mock, patch
|
||||
|
|
@ -173,6 +174,16 @@ from evennia.contrib import extended_room
|
|||
from evennia import gametime
|
||||
from evennia.objects.objects import DefaultRoom
|
||||
|
||||
class ForceUTCDatetime(datetime.datetime):
|
||||
|
||||
"""Force UTC datetime."""
|
||||
|
||||
@classmethod
|
||||
def fromtimestamp(cls, timestamp):
|
||||
"""Force fromtimestamp to run with naive datetimes."""
|
||||
return datetime.datetime.utcfromtimestamp(timestamp)
|
||||
|
||||
@patch('evennia.contrib.extended_room.datetime.datetime', ForceUTCDatetime)
|
||||
class TestExtendedRoom(CommandTest):
|
||||
room_typeclass = extended_room.ExtendedRoom
|
||||
DETAIL_DESC = "A test detail."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue