Fixing tests for new gametime tests
It appears that some mocks setup for gametime in the contrib library were causing issues with the gametime tests. I've switched those mocks to be patches instead so they are cleared out when the test finishes.
This commit is contained in:
parent
a18e724e0b
commit
73f82d0ad1
2 changed files with 13 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ Unit tests for the utilities of the evennia.utils.gametime module.
|
|||
import time
|
||||
from unittest.mock import Mock
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
|
||||
from evennia.utils import gametime
|
||||
|
|
@ -13,12 +14,18 @@ time.time = Mock(return_value=1555595378.0)
|
|||
|
||||
|
||||
class TestGametime(TestCase):
|
||||
def setUp(self):
|
||||
def setUp(self) -> None:
|
||||
gametime.SERVER_RUNTIME = 600.0
|
||||
gametime.SERVER_START_TIME = time.time() - 300
|
||||
gametime.SERVER_RUNTIME_LAST_UPDATED = time.time() - 30
|
||||
gametime.TIMEFACTOR = 5.0
|
||||
|
||||
def tearDown(self) -> None:
|
||||
gametime.SERVER_RUNTIME_LAST_UPDATED = 0.0
|
||||
gametime.SERVER_RUNTIME = 0.0
|
||||
gametime.SERVER_START_TIME = 0.0
|
||||
gametime.TIMEFACTOR = settings.TIME_FACTOR
|
||||
|
||||
def test_runtime(self):
|
||||
self.assertAlmostEqual(gametime.runtime(), 630.0)
|
||||
|
||||
|
|
@ -69,6 +76,7 @@ class TestGametime(TestCase):
|
|||
self.assertIsInstance(script, gametime.TimeScript)
|
||||
self.assertAlmostEqual(script.interval, 17280)
|
||||
self.assertEqual(script.repeats, 1)
|
||||
script.stop()
|
||||
|
||||
def test_repeat_schedule(self):
|
||||
callback = Mock()
|
||||
|
|
@ -76,3 +84,4 @@ class TestGametime(TestCase):
|
|||
self.assertIsInstance(script, gametime.TimeScript)
|
||||
self.assertAlmostEqual(script.interval, 12)
|
||||
self.assertEqual(script.repeats, -1)
|
||||
script.stop()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue