Simplify import plugin unit tests
This commit is contained in:
@@ -26,7 +26,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import locale
|
import locale
|
||||||
from time import localtime, strptime
|
from time import strptime
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
#import logging
|
#import logging
|
||||||
|
|
||||||
@@ -194,20 +194,12 @@ def make_tst_function(tstfile, file_name):
|
|||||||
the test function (a method, to be precise).
|
the test function (a method, to be precise).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@patch('gramps.plugins.db.dbapi.dbapi.time')
|
@patch('time.time', side_effect=mock_time)
|
||||||
@patch('gramps.plugins.db.bsddb.write.time')
|
@patch('time.localtime', side_effect=mock_localtime)
|
||||||
@patch('gramps.gen.utils.unknown.localtime')
|
def tst(self, mock_localtime, mock_time):
|
||||||
@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'
|
""" This compares the import file with the expected result '.gramps'
|
||||||
file.
|
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)
|
fn1 = os.path.join(TEST_DIR, tstfile)
|
||||||
fn2 = os.path.join(TEST_DIR, (file_name + ".gramps"))
|
fn2 = os.path.join(TEST_DIR, (file_name + ".gramps"))
|
||||||
fres = os.path.join(TEMP_DIR, (file_name + ".difs"))
|
fres = os.path.join(TEMP_DIR, (file_name + ".difs"))
|
||||||
|
Reference in New Issue
Block a user