Look for cover art in more places (bug 746)
[gpodder.git] / src / gpodder / unittests.py
blob03471a357f84138cc8c684e619233202b45fc245
1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
6 # gPodder is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # gPodder is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Run Doctests and Unittests for gPodder modules
22 # 2009-02-25 Thomas Perl <thp@gpodder.org>
25 import doctest
26 import unittest
27 import gettext
28 import sys
30 try:
31 import minimock
32 except ImportError, e:
33 print >>sys.stderr, """
34 Error: Unit tests require the "minimock" module (python-minimock).
35 Please install it before running the unit tests.
36 """
37 sys.exit(2)
39 # Which package and which modules in the package should be tested?
40 package = 'gpodder'
41 modules = ['util']
42 coverage_modules = []
44 suite = unittest.TestSuite()
46 for module in modules:
47 m = __import__('.'.join((package, module)), fromlist=[module])
48 coverage_modules.append(m)
49 suite.addTest(doctest.DocTestSuite(m))
51 runner = unittest.TextTestRunner(verbosity=2)
53 try:
54 import coverage
55 except ImportError:
56 coverage = None
58 if coverage is not None:
59 coverage.erase()
60 coverage.start()
62 result = runner.run(suite)
64 if not result.wasSuccessful():
65 sys.exit(1)
67 if coverage is not None:
68 coverage.stop()
69 coverage.report(coverage_modules)
70 coverage.erase()
72 if coverage is None:
73 print >>sys.stderr, """
74 No coverage reporting done (Python module "coverage" is missing)
75 Please install the python-coverage package to get coverage reporting.
76 """