Some error handling/reporting fixes.
[pygobject.git] / tests / runtests-windows.py
blobf9524f447988db1b9e2d8fad2696675646bbf1c9
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
5 import os
6 import sys
7 import glob
8 import unittest
10 mydir = os.path.dirname(os.path.abspath(__file__))
11 tests_builddir = os.path.abspath(os.environ.get('TESTS_BUILDDIR', os.path.dirname(__file__)))
12 builddir = os.path.dirname(tests_builddir)
14 # we have to do this here instead of Makefile.am so that the implicitly added
15 # directory for the source file comes after the builddir
16 sys.path.insert(0, tests_builddir)
17 sys.path.insert(0, builddir)
19 os.environ['PYGTK_USE_GIL_STATE_API'] = ''
20 sys.argv.append('--g-fatal-warnings')
22 from gi.repository import GObject
23 GObject.threads_init()
26 SKIP_FILES = ['runtests',
27 'test_mainloop', # no os.fork on windows
28 'test_subprocess'] # blocks on testChildWatch
31 if __name__ == '__main__':
32 testdir = os.path.split(os.path.abspath(__file__))[0]
33 os.chdir(testdir)
35 def gettestnames():
36 files = glob.glob('*.py')
37 names = map(lambda x: x[:-3], files)
38 map(names.remove, SKIP_FILES)
39 return names
41 suite = unittest.TestSuite()
42 loader = unittest.TestLoader()
44 for name in gettestnames():
45 try:
46 suite.addTest(loader.loadTestsFromName(name))
47 except Exception as e:
48 print('Could not load %s: %s' % (name, e))
50 testRunner = unittest.TextTestRunner()
51 testRunner.verbosity = 2
52 testRunner.run(suite)