~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Lib/json/tests/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import sys
 
3
import unittest
 
4
import doctest
 
5
 
 
6
here = os.path.dirname(__file__)
 
7
 
 
8
def test_suite():
 
9
    suite = additional_tests()
 
10
    loader = unittest.TestLoader()
 
11
    for fn in os.listdir(here):
 
12
        if fn.startswith("test") and fn.endswith(".py"):
 
13
            modname = "json.tests." + fn[:-3]
 
14
            __import__(modname)
 
15
            module = sys.modules[modname]
 
16
            suite.addTests(loader.loadTestsFromModule(module))
 
17
    return suite
 
18
 
 
19
def additional_tests():
 
20
    import json
 
21
    import json.encoder
 
22
    import json.decoder
 
23
    suite = unittest.TestSuite()
 
24
    for mod in (json, json.encoder, json.decoder):
 
25
        suite.addTest(doctest.DocTestSuite(mod))
 
26
    return suite
 
27
 
 
28
def main():
 
29
    suite = test_suite()
 
30
    runner = unittest.TextTestRunner()
 
31
    runner.run(suite)
 
32
 
 
33
if __name__ == '__main__':
 
34
    sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
 
35
    main()