addon-sdk/source/python-lib/cuddlefish/tests/__init__.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial