From b43d94ab16555f0bba21e717bf06bfd3f7ee3575 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Tue, 18 Jul 2017 16:15:01 +0100 Subject: [PATCH] Simplify import plugin unit tests --- gramps/plugins/test/imports_test.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/gramps/plugins/test/imports_test.py b/gramps/plugins/test/imports_test.py index c3a6b3948..41327ac37 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 localtime, strptime +from time import strptime from unittest.mock import patch #import logging @@ -194,20 +194,12 @@ def make_tst_function(tstfile, file_name): the test function (a method, to be precise). """ - @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): + @patch('time.time', side_effect=mock_time) + @patch('time.localtime', side_effect=mock_localtime) + def tst(self, mock_localtime, mock_time): """ 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"))