From a6b96c2419afa6ba91d639352c4d0815350c00bb Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 12 Dec 2017 10:44:53 +0100 Subject: [PATCH] Fix project tests for non-Central time zones When running tests somewhere else than Central Time, `test_api_time()` fails like AssertionError: '1985-10-27T02:00:00' != '1985-10-26T21:00:00' `test_yaps_to_project_info()` fails in a similar way. Pin the time zone to UTC for this test and adjust timestamps to UTC. --- tests/pylorax/test_projects.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/pylorax/test_projects.py b/tests/pylorax/test_projects.py index dfbd56f3..ffd764f8 100644 --- a/tests/pylorax/test_projects.py +++ b/tests/pylorax/test_projects.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +import os +import time import shutil import tempfile import unittest @@ -57,13 +59,15 @@ class ProjectsTest(unittest.TestCase): self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.repo.") self.config = configure(root_dir=self.tmp_dir, test_config=True) self.yb = get_base_object(self.config) + os.environ["TZ"] = "UTC" + time.tzset() @classmethod def tearDownClass(self): shutil.rmtree(self.tmp_dir) def test_api_time(self): - self.assertEqual(api_time(499222800), "1985-10-26T21:00:00") + self.assertEqual(api_time(499222800), "1985-10-27T01:00:00") def test_api_changelog(self): self.assertEqual(api_changelog([[0,1,"Heavy!"]]), "Heavy!") @@ -82,7 +86,7 @@ class ProjectsTest(unittest.TestCase): build = {"epoch":"epoch", "release":"release", "arch":"arch", - "build_time":"1985-10-26T21:00:00", + "build_time":"1985-10-27T01:00:00", "changelog":"Heavy!", "build_config_ref": "BUILD_CONFIG_REF", "build_env_ref": "BUILD_ENV_REF",