From 96ce4838282c4250b34440164a52fe0987f856ae Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Tue, 23 Jul 2013 07:20:11 +0000 Subject: [PATCH] 6938: sys.path broken in unit tests under test/ While at it, also fixed GtkHandler_Test - changed - gtk.main() + while gtk.events_pending(): + gtk.main_iteration() so that the test isn't stuck when done. Note that this test currently is marked as failed as its purpose is to pop up an error dialog. svn: r22724 --- test/GrampsLogger/ErrorReportAssistant_Test.py | 13 ++++++------- test/GrampsLogger/GtkHandler_Test.py | 15 +++++++-------- test/GrampsLogger/RotateLogger_Test.py | 3 ++- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/test/GrampsLogger/ErrorReportAssistant_Test.py b/test/GrampsLogger/ErrorReportAssistant_Test.py index f1d1a07ad..6d454dadc 100644 --- a/test/GrampsLogger/ErrorReportAssistant_Test.py +++ b/test/GrampsLogger/ErrorReportAssistant_Test.py @@ -1,10 +1,12 @@ import unittest import logging import sys +import os log = logging.getLogger('Gramps.Tests.GrampsLogger') - -sys.path.append('..') +import const +const.rootDir = os.path.join(os.path.dirname(__file__), '../../src') +sys.path.append(os.path.join(const.rootDir, 'test')) try: from guitest.gtktest import GtkTestCase TestCaseBase = GtkTestCase @@ -12,11 +14,8 @@ try: except: TestCaseBase = unittest.TestCase -sys.path.append('../../src') -sys.path.append('../../src/GrampsLogger') - -import const -const.rootDir = "../../src" +sys.path.append(const.rootDir) +sys.path.append(os.path.join(const.rootDir, 'GrampsLogger')) from GrampsLogger import RotateHandler diff --git a/test/GrampsLogger/GtkHandler_Test.py b/test/GrampsLogger/GtkHandler_Test.py index 36c8f1bcd..9c620caa8 100644 --- a/test/GrampsLogger/GtkHandler_Test.py +++ b/test/GrampsLogger/GtkHandler_Test.py @@ -2,15 +2,13 @@ import unittest import logging import sys import gtk +import os - -sys.path.append('../../src') -sys.path.append('../../src/GrampsLogger') - -logger = logging.getLogger('Gramps.Tests.GrampsLogger') - +log = logging.getLogger('Gramps.Tests.GrampsLogger') import const -const.rootDir = "../../src" +const.rootDir = os.path.join(os.path.dirname(__file__), '../../src') +sys.path.append(os.path.join(const.rootDir, 'test')) +sys.path.append(const.rootDir) from GrampsLogger import GtkHandler, RotateHandler @@ -41,7 +39,8 @@ class GtkHandlerTest(unittest.TestCase): except: l.error(log_message,exc_info=True) - gtk.main() + while gtk.events_pending(): + gtk.main_iteration() diff --git a/test/GrampsLogger/RotateLogger_Test.py b/test/GrampsLogger/RotateLogger_Test.py index 2b10c077a..bfe773f14 100644 --- a/test/GrampsLogger/RotateLogger_Test.py +++ b/test/GrampsLogger/RotateLogger_Test.py @@ -1,8 +1,9 @@ import unittest import logging import sys +import os -sys.path.append('../../src/GrampsLogger') +sys.path.append(os.path.join(os.path.dirname(__file__), '../../src/GrampsLogger')) logger = logging.getLogger('Gramps.Tests.GrampsLogger')