2009-02-25 14:23:03 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# gPodder - A media aggregator and podcast client
|
|
|
|
# Copyright (c) 2005-2009 Thomas Perl and the gPodder Team
|
|
|
|
#
|
|
|
|
# gPodder 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 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# gPodder 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
# Run Doctests and Unittests for gPodder modules
|
|
|
|
# 2009-02-25 Thomas Perl <thp@gpodder.org>
|
|
|
|
|
|
|
|
|
|
|
|
import doctest
|
|
|
|
import unittest
|
|
|
|
import gettext
|
2009-03-24 15:42:39 +01:00
|
|
|
import sys
|
2009-02-25 14:23:03 +01:00
|
|
|
|
|
|
|
# Which package and which modules in the package should be tested?
|
|
|
|
package = 'gpodder'
|
2009-03-21 21:10:46 +01:00
|
|
|
modules = ['util', 'libtagupdate']
|
2009-03-24 15:42:39 +01:00
|
|
|
coverage_modules = []
|
2009-02-25 14:23:03 +01:00
|
|
|
|
|
|
|
suite = unittest.TestSuite()
|
|
|
|
|
|
|
|
for module in modules:
|
|
|
|
m = __import__('.'.join((package, module)), fromlist=[module])
|
2009-03-24 15:42:39 +01:00
|
|
|
coverage_modules.append(m)
|
2009-02-25 14:23:03 +01:00
|
|
|
# Emulate a globally-installed no-op gettext _() function
|
|
|
|
if not hasattr(m, '_'):
|
|
|
|
setattr(m, '_', lambda x: x)
|
|
|
|
suite.addTest(doctest.DocTestSuite(m))
|
|
|
|
|
|
|
|
runner = unittest.TextTestRunner(verbosity=2)
|
2009-03-24 15:42:39 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
import coverage
|
|
|
|
except ImportError:
|
|
|
|
coverage = None
|
|
|
|
|
|
|
|
if coverage is not None:
|
|
|
|
coverage.erase()
|
|
|
|
coverage.start()
|
|
|
|
|
|
|
|
result = runner.run(suite)
|
|
|
|
|
|
|
|
if not result.wasSuccessful():
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if coverage is not None:
|
|
|
|
coverage.stop()
|
|
|
|
coverage.report(coverage_modules)
|
|
|
|
coverage.erase()
|
|
|
|
|
|
|
|
if coverage is None:
|
|
|
|
print >>sys.stderr, """
|
|
|
|
No coverage reporting done (Python module "coverage" is missing)
|
|
|
|
Please install the python-coverage package to get coverage reporting.
|
|
|
|
"""
|
2009-02-25 14:23:03 +01:00
|
|
|
|