| 1 | #!/usr/bin/python |
|---|
| 2 | # -*- coding: UTF-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2007 Tarek Ziadé <tarek@ziade.org> |
|---|
| 5 | # |
|---|
| 6 | # This program is free software; you can redistribute it and/or |
|---|
| 7 | # modify it under the terms of the GNU General Public License |
|---|
| 8 | # as published by the Free Software Foundation; either version 2 |
|---|
| 9 | # of the License, or (at your option) any later version. |
|---|
| 10 | # |
|---|
| 11 | # This program 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. |
|---|
| 15 | # |
|---|
| 16 | # You should have received a copy of the GNU General Public License |
|---|
| 17 | # along with this program; if not, write to the Free Software |
|---|
| 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | # $Id: addheaders.py 448 2006-10-31 13:31:30Z tarek $ |
|---|
| 20 | import doctest |
|---|
| 21 | import unittest |
|---|
| 22 | import os |
|---|
| 23 | |
|---|
| 24 | flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | |
|---|
| 25 | doctest.REPORT_ONLY_FIRST_FAILURE) |
|---|
| 26 | |
|---|
| 27 | files = [os.path.join('doc', filename) for filename in os.listdir('doc') |
|---|
| 28 | if filename.endswith('.txt')] |
|---|
| 29 | |
|---|
| 30 | def cleanup(): |
|---|
| 31 | top = os.path.join(os.path.dirname(__file__), 'tests/www') |
|---|
| 32 | for root, dirs, files in os.walk(top, topdown=False): |
|---|
| 33 | for name in files: |
|---|
| 34 | os.remove(os.path.join(root, name)) |
|---|
| 35 | for name in dirs: |
|---|
| 36 | os.rmdir(os.path.join(root, name)) |
|---|
| 37 | |
|---|
| 38 | def test_suite(): |
|---|
| 39 | cleanup() |
|---|
| 40 | suite = [] |
|---|
| 41 | for testfile in files: |
|---|
| 42 | suite.append(doctest.DocFileTest(testfile, optionflags=flags)) |
|---|
| 43 | return unittest.TestSuite(suite) |
|---|
| 44 | |
|---|
| 45 | if __name__ == '__main__': |
|---|
| 46 | try: |
|---|
| 47 | unittest.main(defaultTest='test_suite') |
|---|
| 48 | # XXX todo: use setup teardown |
|---|
| 49 | finally: |
|---|
| 50 | cleanup() |
|---|
| 51 | |
|---|
| 52 | |
|---|