Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | import os |
michael@0 | 6 | import unittest |
michael@0 | 7 | import doctest |
michael@0 | 8 | import glob |
michael@0 | 9 | |
michael@0 | 10 | env_root = os.environ['CUDDLEFISH_ROOT'] |
michael@0 | 11 | |
michael@0 | 12 | def get_tests(): |
michael@0 | 13 | import cuddlefish |
michael@0 | 14 | import cuddlefish.tests |
michael@0 | 15 | |
michael@0 | 16 | tests = [] |
michael@0 | 17 | packages = [cuddlefish, cuddlefish.tests] |
michael@0 | 18 | for package in packages: |
michael@0 | 19 | path = os.path.abspath(package.__path__[0]) |
michael@0 | 20 | pynames = glob.glob(os.path.join(path, '*.py')) |
michael@0 | 21 | for filename in pynames: |
michael@0 | 22 | basename = os.path.basename(filename) |
michael@0 | 23 | module_name = os.path.splitext(basename)[0] |
michael@0 | 24 | full_name = "%s.%s" % (package.__name__, module_name) |
michael@0 | 25 | module = __import__(full_name, fromlist=[package.__name__]) |
michael@0 | 26 | |
michael@0 | 27 | loader = unittest.TestLoader() |
michael@0 | 28 | suite = loader.loadTestsFromModule(module) |
michael@0 | 29 | for test in suite: |
michael@0 | 30 | tests.append(test) |
michael@0 | 31 | |
michael@0 | 32 | finder = doctest.DocTestFinder() |
michael@0 | 33 | doctests = finder.find(module) |
michael@0 | 34 | for test in doctests: |
michael@0 | 35 | if len(test.examples) > 0: |
michael@0 | 36 | tests.append(doctest.DocTestCase(test)) |
michael@0 | 37 | |
michael@0 | 38 | return tests |
michael@0 | 39 | |
michael@0 | 40 | def run(verbose=False): |
michael@0 | 41 | if verbose: |
michael@0 | 42 | verbosity = 2 |
michael@0 | 43 | else: |
michael@0 | 44 | verbosity = 1 |
michael@0 | 45 | |
michael@0 | 46 | tests = get_tests() |
michael@0 | 47 | suite = unittest.TestSuite(tests) |
michael@0 | 48 | runner = unittest.TextTestRunner(verbosity=verbosity) |
michael@0 | 49 | return runner.run(suite) |
michael@0 | 50 | |
michael@0 | 51 | if __name__ == '__main__': |
michael@0 | 52 | run() |