2005-12-23 06:10:35 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2014-08-09 07:59:07 +05:30
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-12-23 06:10:35 +05:30
|
|
|
#
|
2005-12-16 17:29:13 +05:30
|
|
|
|
2005-12-23 06:10:35 +05:30
|
|
|
# $Id$
|
|
|
|
|
|
|
|
# Written by Richard Taylor
|
|
|
|
|
|
|
|
"""
|
|
|
|
Testing framework for performing a variety of unttests for GRAMPS.
|
2005-12-16 17:29:13 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import os
|
2005-12-21 16:57:05 +05:30
|
|
|
import sys
|
2005-12-16 17:29:13 +05:30
|
|
|
import unittest
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
Reviving RunAllTests.py on gramps40/trunk
Porting from gramps34 my fix for 6935, 6937, 6938.
Import with full "gramps." qualification from the tests,
to overcome the relative import problem (see bug# 6938 for context).
All testing code has been adjusted to the filename and paths
changes since gramps34.
Same as on gramps34, one test fails still, will investigate if
it is a test or a code bug:
ERROR: test_buffer_recall
(ErrorReportAssistant_Test.ErrorReportAssistantTest)
Test that simple recall of messages works.
----------------------------------------------------------------------
Traceback (most recent call last):
File "./GrampsLogger/ErrorReportAssistant_Test.py", line 60, in
test_buffer_recall
rotate_handler=rh)
File "../gramps/gui/logger/_errorreportassistant.py", line 81, in
__init__
self.build_page1()
File "../gramps/gui/logger/_errorreportassistant.py", line 267, in
build_page1
self._reset_error_details()
File "../gramps/gui/logger/_errorreportassistant.py", line 178, in
_reset_error_details
self._error_detail.get_record()))
AttributeError: 'str' object has no attribute 'get_record'
svn: r22729
2013-07-24 11:53:33 +05:30
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
os.environ['GRAMPS_RESOURCES'] = os.path.join(
|
|
|
|
os.path.dirname(os.path.abspath(__file__)), '..')
|
2005-12-21 16:57:05 +05:30
|
|
|
|
2005-12-16 17:29:13 +05:30
|
|
|
def make_parser():
|
|
|
|
usage = "usage: %prog [options]"
|
|
|
|
parser = OptionParser(usage)
|
|
|
|
parser.add_option("-v", "--verbosity", type="int", dest="verbose_level", default=0,
|
|
|
|
help="Level of verboseness")
|
2005-12-18 02:43:45 +05:30
|
|
|
parser.add_option("-p", "--performance", action="store_true", dest="performance", default=False,
|
|
|
|
help="Run the performance tests.")
|
2005-12-16 17:29:13 +05:30
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def getTestSuites():
|
2005-12-21 16:57:05 +05:30
|
|
|
# Sorry about this line, but it is the easiest way of doing it.
|
|
|
|
# It just walks the filetree from '.' downwards and returns
|
Reviving RunAllTests.py on gramps40/trunk
Porting from gramps34 my fix for 6935, 6937, 6938.
Import with full "gramps." qualification from the tests,
to overcome the relative import problem (see bug# 6938 for context).
All testing code has been adjusted to the filename and paths
changes since gramps34.
Same as on gramps34, one test fails still, will investigate if
it is a test or a code bug:
ERROR: test_buffer_recall
(ErrorReportAssistant_Test.ErrorReportAssistantTest)
Test that simple recall of messages works.
----------------------------------------------------------------------
Traceback (most recent call last):
File "./GrampsLogger/ErrorReportAssistant_Test.py", line 60, in
test_buffer_recall
rotate_handler=rh)
File "../gramps/gui/logger/_errorreportassistant.py", line 81, in
__init__
self.build_page1()
File "../gramps/gui/logger/_errorreportassistant.py", line 267, in
build_page1
self._reset_error_details()
File "../gramps/gui/logger/_errorreportassistant.py", line 178, in
_reset_error_details
self._error_detail.get_record()))
AttributeError: 'str' object has no attribute 'get_record'
svn: r22729
2013-07-24 11:53:33 +05:30
|
|
|
# a tuple per directory of (dirpath,filelist) if the directory
|
2005-12-21 16:57:05 +05:30
|
|
|
# contains any test files.
|
2005-12-16 17:29:13 +05:30
|
|
|
|
2005-12-21 16:57:05 +05:30
|
|
|
paths = [(f[0],f[2]) for f in os.walk('.') \
|
|
|
|
if len ([i for i in f[2] \
|
|
|
|
if i[-8:] == "_Test.py"]) ]
|
|
|
|
|
2013-07-29 22:22:30 +05:30
|
|
|
test_suites = []
|
|
|
|
perf_suites = []
|
|
|
|
|
2005-12-21 16:57:05 +05:30
|
|
|
for (dir,test_modules) in paths:
|
|
|
|
sys.path.append(dir)
|
|
|
|
|
|
|
|
for module in test_modules:
|
|
|
|
if module[-8:] != "_Test.py":
|
Reviving RunAllTests.py on gramps40/trunk
Porting from gramps34 my fix for 6935, 6937, 6938.
Import with full "gramps." qualification from the tests,
to overcome the relative import problem (see bug# 6938 for context).
All testing code has been adjusted to the filename and paths
changes since gramps34.
Same as on gramps34, one test fails still, will investigate if
it is a test or a code bug:
ERROR: test_buffer_recall
(ErrorReportAssistant_Test.ErrorReportAssistantTest)
Test that simple recall of messages works.
----------------------------------------------------------------------
Traceback (most recent call last):
File "./GrampsLogger/ErrorReportAssistant_Test.py", line 60, in
test_buffer_recall
rotate_handler=rh)
File "../gramps/gui/logger/_errorreportassistant.py", line 81, in
__init__
self.build_page1()
File "../gramps/gui/logger/_errorreportassistant.py", line 267, in
build_page1
self._reset_error_details()
File "../gramps/gui/logger/_errorreportassistant.py", line 178, in
_reset_error_details
self._error_detail.get_record()))
AttributeError: 'str' object has no attribute 'get_record'
svn: r22729
2013-07-24 11:53:33 +05:30
|
|
|
continue
|
2005-12-21 16:57:05 +05:30
|
|
|
mod = __import__(module[:-3])
|
|
|
|
test_suites.append(mod.testSuite())
|
|
|
|
try:
|
|
|
|
perf_suites.append(mod.perfSuite())
|
|
|
|
except:
|
|
|
|
pass
|
2005-12-16 17:29:13 +05:30
|
|
|
|
2005-12-18 02:43:45 +05:30
|
|
|
return (test_suites,perf_suites)
|
2005-12-16 17:29:13 +05:30
|
|
|
|
|
|
|
def allTheTests():
|
2005-12-18 02:43:45 +05:30
|
|
|
return unittest.TestSuite(getTestSuites()[0])
|
2005-12-16 17:29:13 +05:30
|
|
|
|
2005-12-18 02:43:45 +05:30
|
|
|
def perfTests():
|
|
|
|
return unittest.TestSuite(getTestSuites()[1])
|
|
|
|
|
2005-12-16 17:29:13 +05:30
|
|
|
if __name__ == '__main__':
|
|
|
|
console = logging.StreamHandler()
|
|
|
|
console.setLevel(logging.INFO)
|
|
|
|
console.setFormatter(logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s'))
|
|
|
|
|
|
|
|
logger = logging.getLogger('Gramps')
|
|
|
|
logger.addHandler(console)
|
|
|
|
|
|
|
|
(options,args) = make_parser().parse_args()
|
|
|
|
|
|
|
|
if options.verbose_level == 1:
|
|
|
|
logger.setLevel(logging.INFO)
|
2005-12-16 22:01:38 +05:30
|
|
|
console.setLevel(logging.INFO)
|
|
|
|
elif options.verbose_level == 2:
|
2005-12-16 17:29:13 +05:30
|
|
|
logger.setLevel(logging.DEBUG)
|
2005-12-16 22:01:38 +05:30
|
|
|
console.setLevel(logging.DEBUG)
|
|
|
|
elif options.verbose_level == 3:
|
|
|
|
logger.setLevel(logging.NOTSET)
|
|
|
|
console.setLevel(logging.NOTSET)
|
|
|
|
elif options.verbose_level >= 4:
|
2005-12-16 17:29:13 +05:30
|
|
|
logger.setLevel(logging.NOTSET)
|
2005-12-16 22:01:38 +05:30
|
|
|
console.setLevel(logging.NOTSET)
|
|
|
|
os.environ['GRAMPS_SIGNAL'] = "1"
|
2005-12-16 17:29:13 +05:30
|
|
|
else:
|
|
|
|
logger.setLevel(logging.ERROR)
|
2005-12-16 22:01:38 +05:30
|
|
|
console.setLevel(logging.ERROR)
|
2005-12-18 02:43:45 +05:30
|
|
|
|
Reviving RunAllTests.py on gramps40/trunk
Porting from gramps34 my fix for 6935, 6937, 6938.
Import with full "gramps." qualification from the tests,
to overcome the relative import problem (see bug# 6938 for context).
All testing code has been adjusted to the filename and paths
changes since gramps34.
Same as on gramps34, one test fails still, will investigate if
it is a test or a code bug:
ERROR: test_buffer_recall
(ErrorReportAssistant_Test.ErrorReportAssistantTest)
Test that simple recall of messages works.
----------------------------------------------------------------------
Traceback (most recent call last):
File "./GrampsLogger/ErrorReportAssistant_Test.py", line 60, in
test_buffer_recall
rotate_handler=rh)
File "../gramps/gui/logger/_errorreportassistant.py", line 81, in
__init__
self.build_page1()
File "../gramps/gui/logger/_errorreportassistant.py", line 267, in
build_page1
self._reset_error_details()
File "../gramps/gui/logger/_errorreportassistant.py", line 178, in
_reset_error_details
self._error_detail.get_record()))
AttributeError: 'str' object has no attribute 'get_record'
svn: r22729
2013-07-24 11:53:33 +05:30
|
|
|
tests = perfTests() if options.performance else allTheTests()
|
|
|
|
unittest.TextTestRunner(verbosity=options.verbose_level).run(tests)
|