diff --git a/gramps/test/test/test_util_test.py b/gramps/test/test/test_util_test.py index 791cba01d..9072a2c25 100644 --- a/gramps/test/test/test_util_test.py +++ b/gramps/test/test/test_util_test.py @@ -184,29 +184,6 @@ class Test3(U.TestCase): else: self.fail("Skip deltree constraint test, no '$HOME' var") -# logging (& misc?) -class Test4(U.TestCase): - logf = "/tmp/__tu__log__" - - def test4a(self): - wmsg = "a warning message" - emsg = "an error message" - import logging - # file logging helps with file capture of log-messages - tl = tu.TestLogger() - for i in (1,2): - # 2 passes to test clearing old file - tl.logfile_init(self.logf) - logging.warn(wmsg) - logging.info("nada") - logging.error(emsg) - ll = tl.logfile_getlines() - nl = len(ll) - print(repr(ll)) - self.assertEquals(nl,2, - tu.msg(nl,2, "pass %d: expected line count" % i)) - #del tl - if __name__ == "__main__": U.main() diff --git a/gramps/test/test_util.py b/gramps/test/test_util.py index 10d541434..81d4c3271 100644 --- a/gramps/test/test_util.py +++ b/gramps/test/test_util.py @@ -172,50 +172,6 @@ def delete_tree(dir): % (dir, here, tmp)) shutil.rmtree(sdir) -# simplified logging -# gramps-independent but gramps-compatible -# -# I don't see any need to inherit from logging.Logger -# (at present, test code needs nothing fancy) -# but that might be considered for future needs -# NB: current code reflects limited expertise on the -# uses of the logging module -# --------------------------------------------------------- -class TestLogger: - """this class mainly just encapsulates some globals - namely lfname, lfh for a file log name and handle - - provides simplified logging setup for test modules - that need to setup logging for modules under test - (just instantiate a TestLogger to avoid error - messages about logging handlers not available) - - There is also a simple logfile capability, to allow - test modules to capture gramps logging output - - Note that existing logging will still occur, possibly - resulting in console messages and popup dialogs - """ - def __init__(self, lvl=logging.WARN): - logging.basicConfig(level=lvl) - - def logfile_init(self, lfname): - """init or re-init a logfile""" - if getattr(self, "lfh", None): - logging.getLogger().handlers.remove(self.lfh) - if os.path.isfile(lfname): - os.unlink(lfname) - self.lfh = logging.FileHandler(lfname) - logging.getLogger().addHandler(self.lfh) - self.lfname = lfname - - def logfile_getlines(self): - """get current content of logfile as list of lines""" - txt = [] - if self.lfname and os.path.isfile(self.lfname): - txt = open(self.lfname).readlines() - return txt - ### Support for testing CLI def new_exit(edit_code=None):