Beispiel #1
0
def load_tests(loader, standard_tests, pattern):
    suite = TestSuite()
    frame_proxy_tests = defaultTestLoader.loadTestsFromModule(xlmap)
    xl_types_tests = defaultTestLoader.loadTestsFromModule(xl_types)
    indexer_tests = defaultTestLoader.loadTestsFromModule(indexers)
    suite.addTests(frame_proxy_tests)
    suite.addTests(xl_types_tests)
    suite.addTest(indexer_tests)
    suite.addTest(charts.suite)
    return suite
Beispiel #2
0
    def run (self):
        """Run the test suite."""
        import testsuite.test_support as test_support

        if self.pdb and self.test != ['test_gdb']:
            print('One can only debug a gdb test case for now.')
            return

        testsuite = 'testsuite'
        tests = ['test_' + t for t in self.test.split(',')]
        if self.prefix:
            defaultTestLoader.testMethodPrefix = self.prefix
        for test in tests:
            the_module = importlib.import_module('.%s' % test, testsuite)
            suite = defaultTestLoader.loadTestsFromModule(the_module)
            if self.pdb and (len(tests) > 1 or suite.countTestCases() > 1):
                print('Only one test at a time can be debugged, use the'
                      ' \'--test=\' and \'--prefix=\' options to set'
                      ' this test.')
                return
            if test == 'test_gdb':
                subprocess.check_call(['make', '-C', testsuite])
            # run the test
            print(the_module.__name__)
            sys.stdout.flush()
            test_support.run_suite(suite, self.detail, self.stop, self.pdb)
Beispiel #3
0
 def run(self):
     if ((sys.version_info > (3, 2, 0, 'final', 0)) or
         (sys.version_info > (2, 7, 0, 'final', 0) and sys.version_info < (3, 0, 0, 'final', 0))):
         from unittest import TextTestRunner, defaultTestLoader
     else:
         try:
             from unittest2 import TextTestRunner, defaultTestLoader
         except ImportError:
             print("Please install unittest2 to run the test suite")
             exit(-1)
     from tests import test_scrypt, test_scrypt_py2x, test_scrypt_py3x
     suite = defaultTestLoader.loadTestsFromModule(test_scrypt)
     suite.addTests(defaultTestLoader.loadTestsFromModule(test_scrypt_py2x))
     suite.addTests(defaultTestLoader.loadTestsFromModule(test_scrypt_py3x))
     runner = TextTestRunner()
     result = runner.run(suite)
Beispiel #4
0
    def run(self):
        """Run the test suite."""
        import testsuite.test_support as test_support

        if self.pdb and self.test != ['test_gdb']:
            print('One can only debug a gdb test case for now.')
            return

        testsuite = 'testsuite'
        tests = ['test_' + t for t in self.test.split(',')]
        if self.prefix:
            defaultTestLoader.testMethodPrefix = self.prefix
        for test in tests:
            the_module = importlib.import_module('.%s' % test, testsuite)
            suite = defaultTestLoader.loadTestsFromModule(the_module)
            if self.pdb and (len(tests) > 1 or suite.countTestCases() > 1):
                print('Only one test at a time can be debugged, use the'
                      ' \'--test=\' and \'--prefix=\' options to set'
                      ' this test.')
                return
            if test == 'test_gdb':
                subprocess.check_call(['make', '-C', testsuite])
            # run the test
            print(the_module.__name__)
            sys.stdout.flush()
            test_support.run_suite(suite, self.detail, self.stop, self.pdb)
Beispiel #5
0
def test_suite():
    from unittest import defaultTestLoader as TL
    from unittest import TestSuite as TS
    tests = []
    import test_odtxsl as T
    tests.append(T)
    import test_xmlformat as T
    tests.append(T)
    import test_xmlmodel as T
    tests.append(T)
    import test_binmodel as T
    tests.append(T)
    import test_recordstream as T
    tests.append(T)
    import test_filestructure as T
    tests.append(T)
    import test_dataio as T
    tests.append(T)
    import test_treeop as T
    tests.append(T)
    import test_ole as T
    tests.append(T)
    import test_storage as T
    tests.append(T)

    # localtest: a unittest module which resides at the local test site only;
    # should not be checked in the source code repository
    try:
        import localtest
    except ImportError as e:
        print('localtest import failed: ', e)
    else:
        tests[0:0] = [localtest]

    return TS((TL.loadTestsFromModule(m) for m in tests))
Beispiel #6
0
def test_suite():
    from unittest import defaultTestLoader as TL
    from unittest import TestSuite as TS
    import test_treeop
    import test_binmodel
    import test_dataio
    import test_xmlmodel
    import test_xmlformat
    import test_filestructure
    import test_storage
    import test_recordstream
    import test_odtxsl

    tests = [test_storage, test_filestructure, test_binmodel, test_dataio, test_xmlmodel, test_xmlformat, test_odtxsl]
    tests.append(test_recordstream)
    tests.append(test_treeop)

    # localtest: a unittest module which resides at the local test site only;
    # should not be checked in the source code repository
    try:
        import localtest
    except ImportError:
        pass
    else:
        tests[0:0] = [localtest]

    return TS((TL.loadTestsFromModule(m) for m in tests))
Beispiel #7
0
 def tests(self):
     from unittest import defaultTestLoader
     yield defaultTestLoader.loadTestsFromTestCase(DetectorTest)
     yield defaultTestLoader.loadTestsFromTestCase(ImporterTest)
     from hwp5_uno.tests import test_hwp5_uno
     yield defaultTestLoader.loadTestsFromModule(test_hwp5_uno)
     from hwp5.tests import test_suite
     yield test_suite()
def make_suite(prefix='tests.', extra=(), force_all=False):
    tests = TESTS + extra
    test_names = list(prefix + x for x in tests)
    suite = TestSuite()
    for name in test_names:
        module = import_module(name)
        suite.addTest(defaultTestLoader.loadTestsFromModule(module))
    return suite
Beispiel #9
0
 def tests(self):
     from unittest import defaultTestLoader
     yield defaultTestLoader.loadTestsFromTestCase(DetectorTest)
     yield defaultTestLoader.loadTestsFromTestCase(ImporterTest)
     from hwp5_uno.tests import test_hwp5_uno
     yield defaultTestLoader.loadTestsFromModule(test_hwp5_uno)
     from hwp5.tests import test_suite
     yield test_suite()
def make_suite(prefix='tests.', extra=(), force_all=False):
    tests = TESTS + extra
    test_names = list(prefix + x for x in tests)
    suite = TestSuite()
    for name in test_names:
        module = import_module(name)
        suite.addTest(defaultTestLoader.loadTestsFromModule(module))
    return suite
Beispiel #11
0
    def _get_test_suite(self):
        from unittest import TestSuite, defaultTestLoader
        import core.cpu.tests as tests1

        suite = TestSuite()

        for t in (tests1, ):
            suite.addTests(defaultTestLoader.loadTestsFromModule(t))

        return suite
Beispiel #12
0
def suite():
    mod_path = os.path.dirname(inspect.getfile(lambda foo:foo))
    sys.path.append(mod_path + os.sep + "..")
    s = unittest.TestSuite()
    for moduleName in glob(mod_path + os.sep + "test_*.py"):
        moduleName = os.path.basename(moduleName)
        moduleName = moduleName.replace('.py', '')
        if moduleName != 'test_all':
            testModule = __import__(moduleName)
            s.addTest(defaultTestLoader.loadTestsFromModule(testModule))
    return s
Beispiel #13
0
def suite():
    mod_path = os.path.dirname(inspect.getfile(lambda foo: foo))
    sys.path.append(mod_path + os.sep + "..")
    s = unittest.TestSuite()
    for moduleName in glob(mod_path + os.sep + "test_*.py"):
        moduleName = os.path.basename(moduleName)
        moduleName = moduleName.replace('.py', '')
        if moduleName != 'test_all':
            testModule = __import__(moduleName)
            s.addTest(defaultTestLoader.loadTestsFromModule(testModule))
    return s
Beispiel #14
0
    def run(self):
        """Run the test suite."""
        result_tmplt = '{} ... {:d} tests with zero failures'
        optionflags = doctest.REPORT_ONLY_FIRST_FAILURE if self.stop else 0
        cnt = ok = 0
        # Make sure we are testing the installed version of pdb_clone.
        if 'pdb_clone' in sys.modules:
            del sys.modules['pdb_clone']
        sys.path.pop(0)
        import pdb_clone

        for test in self.tests:
            cnt += 1
            with support.temp_cwd() as cwd:
                sys.path.insert(0, os.getcwd())
                try:
                    savedcwd = support.SAVEDCWD
                    shutil.copytree(os.path.join(savedcwd, 'testsuite'),
                                    os.path.join(cwd, 'testsuite'))
                    # Some unittest tests spawn pdb-clone.
                    shutil.copyfile(os.path.join(savedcwd, 'pdb-clone'),
                                    os.path.join(cwd, 'pdb-clone'))
                    abstest = self.testdir + '.' + test
                    module = importlib.import_module(abstest)
                    suite = defaultTestLoader.loadTestsFromModule(module)
                    unittest_count = suite.countTestCases()
                    # Change the module name to allow correct doctest checks.
                    module.__name__ = 'test.' + test
                    print('{}:'.format(abstest))
                    f, t = doctest.testmod(module,
                                           verbose=self.detail,
                                           optionflags=optionflags)
                    if f:
                        print('{:d} of {:d} doctests failed'.format(f, t))
                    elif t:
                        print(result_tmplt.format('doctest', t))

                    try:
                        support.run_unittest(suite)
                    except support.TestFailed as msg:
                        print('test', test, 'failed --', msg)
                    else:
                        print(result_tmplt.format('unittest', unittest_count))
                        if not f:
                            ok += 1
                finally:
                    sys.path.pop(0)
        failed = cnt - ok
        cnt = failed if failed else ok
        plural = 's' if cnt > 1 else ''
        result = 'failed' if failed else 'ok'
        print('{:d} test{} {}.'.format(cnt, plural, result))
Beispiel #15
0
def suite():
    result = TestSuite()

    result.addTest(doctest.DocTestSuite("django_any.xunit"))
    result.addTest(doctest.DocTestSuite("django_any.forms"))

    for filename in glob(os.path.join(TESTS_ROOT, "*.py")):
        if filename.endswith("__init__.py"):
            continue

        module_name = "django_any.tests.%s" % os.path.splitext(os.path.basename(filename))[0]
        __import__(module_name)

        result.addTest(defaultTestLoader.loadTestsFromModule(sys.modules[module_name]))

    return result
Beispiel #16
0
def suite():
    result = TestSuite()

    result.addTest(doctest.DocTestSuite('django_any.xunit'))
    result.addTest(doctest.DocTestSuite('django_any.forms'))

    for filename in glob(os.path.join(TESTS_ROOT, '*.py')):
        if filename.endswith('__init__.py'):
            continue

        module_name = 'django_any.tests.%s' % \
                      os.path.splitext(os.path.basename(filename))[0]
        __import__(module_name)

        result.addTest(
            defaultTestLoader.loadTestsFromModule(sys.modules[module_name]))

    return result
Beispiel #17
0
def _add_tests_for_module(suite, module):
    """
    Repeated code from inside `build_suite()` is refactored here.
    """
    # Load unit and doctests in the given module. If module has a suite()
    # method, use it. Otherwise build the test suite ourselves.
    if hasattr(module, 'suite'):
        suite.addTest(module.suite())
    else:
        suite.addTest(defaultTestLoader.loadTestsFromModule(module))
        try:
            suite.addTest(doctest.DocTestSuite(
                module,
                checker=doctestOutputChecker,
                runner=DocTestRunner,
                optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
        except ValueError:
            # No doc tests in models.py
            pass
Beispiel #18
0
def suite():
    """
    Creates a ``TestSuite`` containing ``TestCase``s from all modules
    whose filenames end with 'test.py' in this directory and
    ``TestCase``s created from modules which have doctests.
    """
    path = os.path.abspath(os.path.dirname(__file__))
    app_name = os.path.basename(os.path.dirname(path))
    test_files = [f for f in os.listdir(path) if test_file_re.search(f)]
    module_names = ['%s.tests.%s' % (app_name, os.path.splitext(f)[0]) \
                    for f in test_files]
    modules = [__import__(module_name, globals(), locals(), ['']) \
               for module_name in module_names]
    suite = TestSuite([defaultTestLoader.loadTestsFromModule(module) \
                       for module in modules])

    # Create TestCases from modules which have doctests
    doctest_module_names = ['%s.%s' % (app_name, m) for m in doctests]
    doctest_modules = [__import__(module_name, globals(), locals(), ['']) \
                       for module_name in doctest_module_names]
    for doctest_module in doctest_modules:
        suite.addTest(doctest.DocTestSuite(doctest_module))

    return suite
Beispiel #19
0
def suite():
    """
    Creates a ``TestSuite`` containing ``TestCase``s from all modules
    whose filenames end with 'test.py' in this directory and
    ``TestCase``s created from modules which have doctests.
    """
    path = os.path.abspath(os.path.dirname(__file__))
    app_name = os.path.basename(os.path.dirname(path))
    test_files = [f for f in os.listdir(path) if test_file_re.search(f)]
    module_names = ['%s.tests.%s' % (app_name, os.path.splitext(f)[0]) \
                    for f in test_files]
    modules = [__import__(module_name, globals(), locals(), ['']) \
               for module_name in module_names]
    suite = TestSuite([defaultTestLoader.loadTestsFromModule(module) \
                       for module in modules])

    # Create TestCases from modules which have doctests
    doctest_module_names = ['%s.%s' % (app_name, m) for m in doctests]
    doctest_modules = [__import__(module_name, globals(), locals(), ['']) \
                       for module_name in doctest_module_names]
    for doctest_module in doctest_modules:
        suite.addTest(doctest.DocTestSuite(doctest_module))

    return suite
Beispiel #20
0
def run_module_tests(module):
    test_suite = defaultTestLoader.loadTestsFromModule(module)
    test_result = TestResult()
    test_suite.run(test_result)
    return test_result
Beispiel #21
0
from unittest import defaultTestLoader


for module_name in ['test_mllp']:
    module = __import__(module_name, globals(), level=-1)
    defaultTestLoader.loadTestsFromModule(module)
    
Beispiel #22
0
import os
from unittest import defaultTestLoader, TestSuite
import api
import apikey
import artist
import base
import lyrics
import subtitle
import track
import album

suite = TestSuite()
suite.addTest(defaultTestLoader.loadTestsFromModule(api))
suite.addTest(defaultTestLoader.loadTestsFromModule(artist))
suite.addTest(defaultTestLoader.loadTestsFromModule(base))
suite.addTest(defaultTestLoader.loadTestsFromModule(lyrics))
suite.addTest(defaultTestLoader.loadTestsFromModule(subtitle))
suite.addTest(defaultTestLoader.loadTestsFromModule(track))
suite.addTest(defaultTestLoader.loadTestsFromModule(album))
# if os.environ.get('musixmatch_apikey', None):
#     suite.addTest(defaultTestLoader.loadTestsFromModule(apikey))

# suite.addTest(api.TestError())
# suite.addTest(api.TestResponseStatusCode())
# suite.addTest(api.TestResponseMessage())
# suite.addTest(api.TestXMLResponseMessage())
# suite.addTest(api.TestJsonResponseMessage())
# suite.addTest(api.TestQueryString())
# suite.addTest(api.TestRequest())
# suite.addTest(api.TestMethod())
# suite.addTest(base.TestBase())
Beispiel #23
0
def tests_from_modules(*modules):
    """Returns a unittest.TestSuite containing tests loaded from all the
    modules listed in *modules*.

    """
    return Suite([loader.loadTestsFromModule(module) for module in modules])
Beispiel #24
0
def run_tests():
    import sys
    this_module = sys.modules[__name__]
    tests = defaultTestLoader.loadTestsFromModule(this_module)
    TextTestRunner().run(tests)
Beispiel #25
0
    import test_xmlformat as T
    tests.append(T)
    import test_xmlmodel as T
    tests.append(T)
    import test_binmodel as T
    tests.append(T)
    import test_recordstream as T
    tests.append(T)
    import test_filestructure as T
    tests.append(T)
    import test_dataio as T
    tests.append(T)
    import test_treeop as T
    tests.append(T)
    import test_ole as T
    tests.append(T)
    import test_storage as T
    tests.append(T)

    # localtest: a unittest module which resides at the local test site only;
    # should not be checked in the source code repository
    try:
        import localtest
    except ImportError, e:
        print 'localtest import failed: ', e
        pass
    else:
        tests[0:0] = [localtest]

    return TS((TL.loadTestsFromModule(m) for m in tests))
Beispiel #26
0
def run_tests():
    import sys; this_module = sys.modules[__name__]
    tests = defaultTestLoader.loadTestsFromModule(this_module)
    TextTestRunner().run(tests)
Beispiel #27
0
from unittest import defaultTestLoader

for module_name in ['test_mllp']:
    module = __import__(module_name, globals(), level=-1)
    defaultTestLoader.loadTestsFromModule(module)
 def run_tests(self):
     suite = defaultTestLoader.loadTestsFromModule(SublimeCscope.sublime_cscope.tests)
     runner = TextTestRunner()
     runner.run(suite)
     _load_plugin()
def suite():
    suite = TestSuite()
    suite.addTest(defaultTestLoader.loadTestsFromModule(models.tests))
    suite.addTest(defaultTestLoader.loadTestsFromModule(forms.tests))
    suite.addTest(defaultTestLoader.loadTestsFromModule(templatetags.tests))
    return suite
Beispiel #30
0
#!/usr/bin/python
import unittest
from unittest import defaultTestLoader
import sys
import logging
import test_pysimplesoap


if __name__ == '__main__':
    FORMAT = "%(asctime)s %(levelname)6s %(message)s"
    logging.basicConfig(level=logging.DEBUG, format=FORMAT, datefmt='%m%d%H%M%S', stream=sys.stdout)
    runner = unittest.TextTestRunner()
    suite = unittest.TestSuite()
    suite.addTests(defaultTestLoader.loadTestsFromModule(test_pysimplesoap))
    result = runner.run(suite)
    if not result.wasSuccessful():
        sys.exit(-1)
Beispiel #31
0
from unittest import defaultTestLoader, TestSuite
from . import test_generator
from . import test_functions

suite = TestSuite()
suite.addTest(defaultTestLoader.loadTestsFromModule(test_generator))
suite.addTest(defaultTestLoader.loadTestsFromModule(test_functions))
Beispiel #32
0
from . import test_exon
from . import test_protein
from . import test_sequence

from unittest import TestSuite, defaultTestLoader

suite = TestSuite()
suite.addTest(defaultTestLoader.loadTestsFromModule(test_exon))
suite.addTest(defaultTestLoader.loadTestsFromModule(test_protein))
suite.addTest(defaultTestLoader.loadTestsFromModule(test_sequence))

if __name__ == "__main__":
    unittest.TextTestRunner(verbosity=2).run(suite)
def run_module_tests(module):
    test_suite = defaultTestLoader.loadTestsFromModule(module)
    test_result = TestResult()
    test_suite.run(test_result)
    return test_result