3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU Library General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # See the COPYING file for license information.
19 # Copyright (c) 2006, 2007 Guillaume Chazarain <guichaz@yahoo.fr>
30 PYSIZE_EXAMPLE_PATH
= '/tmp/pysize_example_dir'
31 ALL_TESTS
= unittest
.TestSuite()
34 if not os
.path
.exists('/tmp/pysize_example_dir'):
35 tar
= tarfile
.open('pysize_example_dir.tar.bz2', 'r:bz2')
36 print 'Extracting pysize_example_dir.tar.bz2'
38 tar
.extract(tarinfo
, '/tmp')
42 print 'Removing', PYSIZE_EXAMPLE_PATH
43 shutil
.rmtree(PYSIZE_EXAMPLE_PATH
)
46 py_files
= [p
for p
in os
.listdir('tests') if p
.endswith('.py')]
47 tests
= list(set([p
[:p
.index('.')] for p
in py_files
]))
49 module
= getattr(__import__('tests.' + name
), name
)
50 for test
in module
.TESTS
:
51 suite
= unittest
.defaultTestLoader
.loadTestsFromTestCase(test
)
52 ALL_TESTS
.addTest(suite
)
55 parser
= optparse
.OptionParser()
56 parser
.add_option('--keep', '-k', action
='store_true', dest
='keep',
57 default
=False, help='keep /tmp/pysize_example_dir')
58 parser
.add_option('--coverage', '-c', action
='store_true', dest
='coverage',
59 default
=False, help='include coverage tests')
60 options
, args
= parser
.parse_args()
72 for name
, module
in sys
.modules
.iteritems():
73 if name
.startswith('pysize.') and module
:
74 path
= '../' + name
.replace('.', '/') + '.py'
75 if os
.path
.exists(path
):
76 modules
.append(module
)
77 coverage
.report(modules
)
81 options
= parse_cmdline()
82 sys
.path
.insert(0, '..')
88 unittest
.main(argv
=[sys
.argv
[0], '-v'], defaultTest
='ALL_TESTS')
95 if __name__
== '__main__':