]> git.decadent.org.uk Git - dak.git/blob - tests/test_all.py
suppress warnings when running tests in squeeze
[dak.git] / tests / test_all.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import os
5 import unittest
6 import warnings
7
8 # suppress some deprecation warnings in squeeze related to apt_pkg,
9 # debian, and md5 modules
10 warnings.filterwarnings('ignore', \
11     "Attribute '.*' of the 'apt_pkg\.Configuration' object is deprecated, use '.*' instead\.", \
12     DeprecationWarning)
13 warnings.filterwarnings('ignore', \
14     "apt_pkg\.newConfiguration\(\) is deprecated\. Use apt_pkg\.Configuration\(\) instead\.", \
15     DeprecationWarning)
16 warnings.filterwarnings('ignore', \
17     "please use 'debian' instead of 'debian_bundle'", \
18     DeprecationWarning)
19 warnings.filterwarnings('ignore', \
20     "the md5 module is deprecated; use hashlib instead", \
21     DeprecationWarning)
22
23 def suite():
24     suite = unittest.TestSuite()
25     for _, _, files in os.walk('.'):
26         for name in filter(is_test, files):
27             tests = unittest.defaultTestLoader.loadTestsFromName(name[:-3])
28             suite.addTests(tests)
29     return suite
30
31 def is_test(filename):
32     return filename.startswith('test_') and filename.endswith('.py')
33
34 if __name__ == "__main__":
35     unittest.main(defaultTest="suite")