root/geojson/trunk/tests/test_doctests.py

Revision 1062 (checked in by seang, 8 months ago)

Add a test suite to the setup script

  • Property svn:eol-style set to native
Line 
1 # ============================================================================
2 # GeoJSON. Copyright (C) 2007 Sean C. Gillies
3 #
4 # See ../LICENSE.txt
5 #
6 # Contact: Sean Gillies, sgillies@frii.com
7 # ============================================================================
8 import unittest
9 import glob
10 import os
11
12 import doctest
13
14 optionflags = (doctest.REPORT_ONLY_FIRST_FAILURE |
15                doctest.NORMALIZE_WHITESPACE |
16                doctest.ELLIPSIS)
17
18 def list_doctests():
19     return [filename
20             for filename
21             in glob.glob(os.path.join(os.path.dirname(__file__), '*.txt'))]
22
23 def open_file(filename, mode='r'):
24     """Helper function to open files from within the tests package."""
25     return open(os.path.join(os.path.dirname(__file__), filename), mode)
26
27 def setUp(test):
28     test.globs.update(dict(
29             open_file = open_file,
30             ))
31
32 def test_suite():
33     return unittest.TestSuite(
34         [doctest.DocFileSuite(os.path.basename(filename),
35                               optionflags=optionflags,
36                               setUp=setUp)
37          for filename
38          in list_doctests()])
Note: See TracBrowser for help on using the browser.