root/releases/pkgcore/0.1.1/sandbox/test.py @ ferringb%2540gentoo.org-20060929013225-51aab20844798ab0

Revision ferringb%2540gentoo.org-20060929013225-51aab20844798ab0, 1.3 KB (checked in by Brian Harring <ferringb@…>, 2 years ago)

force sys.path insertion for tests.

  • Property executable set to True
Line 
1#!/usr/bin/env python
2
3# Copyright: 2006 Marien Zwart <marienz@gentoo.org>
4# License: GPL2
5
6"""Very minimal test runner."""
7import os.path
8import sys
9import unittest
10
11# ensure pkgcore is in sys.path
12sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
13
14# XXX nasty hack: point the plugin system at a predefined directory
15# (to make it work without the global plugin registry being there).
16# The plugin system reworking should kill this.
17from pkgcore import const
18const.plugins_dir = os.path.join(os.path.dirname(__file__), 'test-plugins')
19
20from pkgcore import test
21from pkgcore.util import modules
22
23if __name__ == '__main__':
24    suites = []
25    testpath = test.__path__[0]
26    for root, dirs, files in os.walk(testpath):
27        if '__init__.py' not in files:
28            continue
29        prefix = root[len(testpath):].replace(os.sep, '.')
30        for mod in files:
31            if mod.startswith('test') and mod.endswith('.py'):
32                module = modules.load_module('pkgcore.test%s.%s' % (
33                        prefix, mod[:-3]))
34                suite = unittest.defaultTestLoader.loadTestsFromModule(module)
35                suites.append(suite)
36    result = unittest.TextTestRunner().run(unittest.TestSuite(suites))
37    sys.exit(not result.wasSuccessful())
Note: See TracBrowser for help on using the browser.