From 7ebd6a9f0efe1badc2f15d5f5b83d6e91db817cb Mon Sep 17 00:00:00 2001 From: Chason Chaffin Date: Fri, 19 Apr 2019 12:49:27 +0900 Subject: [PATCH] testing for bug found in gametime module I've found a bug in the gametime module where if your date is the year before a leap year, and the real_seconds_until function has to adjust the date (from using an earlier month) over that leap year, the calculation is off a day since the current function uses the length of the current year to determine how far to skip ahead I've changed the current test to *not* test for this bug in the mainline test (before it was passing because I was using the output from the current function to determine correctness) and to add a separate test that is marked as an expected failure for now. I am working on a fix but it is outside the scope of this PR. --- evennia/utils/tests/test_gametime.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/evennia/utils/tests/test_gametime.py b/evennia/utils/tests/test_gametime.py index fff07b9399..cc2a759c18 100644 --- a/evennia/utils/tests/test_gametime.py +++ b/evennia/utils/tests/test_gametime.py @@ -3,6 +3,7 @@ Unit tests for the utilities of the evennia.utils.gametime module. """ import time +import unittest from unittest.mock import Mock from django.conf import settings @@ -75,7 +76,11 @@ class TestGametime(TestCase): self.assertAlmostEqual(gametime.real_seconds_until(min=30), 708) self.assertAlmostEqual(gametime.real_seconds_until(hour=13), 16560) self.assertAlmostEqual(gametime.real_seconds_until(day=17), 501120) - self.assertAlmostEqual(gametime.real_seconds_until(month=3), 5771520) + self.assertAlmostEqual(gametime.real_seconds_until(month=1), 4752000) + + @unittest.expectedFailure + def test_real_seconds_until_leap_year(self): + self.assertAlmostEqual(gametime.real_seconds_until(month=3), 5788800) def test_schedule(self): callback = Mock()