diff --git a/gramps/gen/utils/unknown.py b/gramps/gen/utils/unknown.py index 0221e423d..3d34cc832 100644 --- a/gramps/gen/utils/unknown.py +++ b/gramps/gen/utils/unknown.py @@ -29,7 +29,7 @@ Make an 'Unknown' primary object # Python modules # #------------------------------------------------------------------------- -from time import strftime, time +from time import strftime, localtime, time import os #------------------------------------------------------------------------- @@ -147,7 +147,7 @@ def make_unknown(class_arg, explanation, class_func, commit_func, transaction, if not hasattr(make_unknown, 'count'): make_unknown.count = 1 #primitive static variable obj.set_name(_("Unknown, was missing %(time)s (%(count)d)") % { - 'time': strftime('%x %X'), + 'time': strftime('%x %X', localtime()), 'count': make_unknown.count}) make_unknown.count += 1 else: @@ -167,7 +167,7 @@ def create_explanation_note(dbase): """ note = Note( _('Objects referenced by this note ' 'were missing in a file imported on %s.') % - strftime('%x %X')) + strftime('%x %X', localtime())) note.set_handle(create_id()) note.set_gramps_id(dbase.find_next_note_gramps_id()) # Use defaults for privacy, format and type. diff --git a/gramps/plugins/importer/importprogen.py b/gramps/plugins/importer/importprogen.py index bae842860..0f951d7c2 100644 --- a/gramps/plugins/importer/importprogen.py +++ b/gramps/plugins/importer/importprogen.py @@ -213,7 +213,7 @@ class ProgenOptions(ManagedWindow): # initial values text = "Pro-Gen Import" fname = os.path.basename(filename).split('\\')[-1] - date = time.strftime("%Y-%m-%d") + date = time.strftime('%Y-%m-%d', time.localtime()) # add import source title/confidence # citation page/confidence/privacy/attribute diff --git a/gramps/plugins/test/imports_test.py b/gramps/plugins/test/imports_test.py index 65d77650b..c3a6b3948 100644 --- a/gramps/plugins/test/imports_test.py +++ b/gramps/plugins/test/imports_test.py @@ -26,7 +26,7 @@ import os import sys import re import locale -from time import strptime, strftime +from time import localtime, strptime from unittest.mock import patch #import logging @@ -65,12 +65,6 @@ def mock_localtime(*args): """ return strptime("25 Dec 1999", "%d %b %Y") -def mock_strftime(*args): - """ - Mock up a dummy to replace the varying 'time string results' - """ - return strftime(args[0], (1999, 12, 25, 0, 0, 0, 5, 359, -1)) - class TestImports(unittest.TestCase): """The test class cases will be dynamically created at import time from files to be tested. The following defs are used by the test cases @@ -199,12 +193,21 @@ def make_tst_function(tstfile, file_name): """ This is here to support the dynamic function creation. This creates the test function (a method, to be precise). """ - @patch('gramps.gen.utils.unknown.strftime', side_effect=mock_strftime) - @patch('time.strftime', side_effect=mock_strftime) - def tst(self, mstrftime1, mstrftime2): + + @patch('gramps.plugins.db.dbapi.dbapi.time') + @patch('gramps.plugins.db.bsddb.write.time') + @patch('gramps.gen.utils.unknown.localtime') + @patch('gramps.gen.utils.unknown.time') + @patch('time.localtime') + def tst(self, mockptime, mocktime, mockltime, mockwtime, mockdtime): """ This compares the import file with the expected result '.gramps' file. """ + mockptime.side_effect = mock_localtime + mocktime.side_effect = mock_time + mockltime.side_effect = mock_localtime + mockwtime.side_effect = mock_time + mockdtime.side_effect = mock_time fn1 = os.path.join(TEST_DIR, tstfile) fn2 = os.path.join(TEST_DIR, (file_name + ".gramps")) fres = os.path.join(TEMP_DIR, (file_name + ".difs"))