Example #1
0
def suite():
    
    simple = unittest.TestLoader().loadTestsFromTestCase(SimpleNav)
    data = unittest.TestLoader().loadTestsFromTestCase(DataNav)
    uact = unittest.TestLoader().loadTestsFromTestCase(UserActions)
    
    suite = unittest.TestSuite( [ uact, simple, data ])
    
    return suite
Example #2
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
        test_twitter_views.TwitterViewsTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
        test_twitter_api.TwitterApiTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
        test_views.ViewsTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
        test_scheduler.SchedulerTestCase))
    return suite
Example #3
0
def build_suite(app_module):
    """
    Create a complete Django test suite for the provided application module.
    """
    suite = unittest.TestSuite()

    # Load unit and doctests in the models.py module. If module has
    # a suite() method, use it. Otherwise build the test suite ourselves.
    if hasattr(app_module, 'suite'):
        test = app_module.suite()
        if len(test._tests) > 0:
            suite.addTests(test._tests)
    else:
        test = unittest.TestLoader().loadTestsFromModule(app_module)
        if len(test._tests) > 0:
            suite.addTests(test._tests)
        try:
            test = doctest.DocTestSuite(app_module,
                                        checker=doctestOutputChecker,
                                        runner=DocTestRunner)
            if len(test._tests) > 0:
                suite.addTests(test._tests)
        except ValueError:
            # No doc tests in models.py
            pass

    # Check to see if a separate 'tests' module exists parallel to the
    # models module
    test_module = get_tests(app_module)
    if test_module:
        # Load unit and doctests in the tests.py module. If module has
        # a suite() method, use it. Otherwise build the test suite ourselves.
        if hasattr(test_module, 'suite'):
            test = test_module.suite()
            if len(test._tests) > 0:
                suite.addTests(test._tests)
        else:
            test = unittest.TestLoader().loadTestsFromModule(test_module)
            if len(test._tests) > 0:
                suite.addTests(test._tests)
            try:
                test = doctest.DocTestSuite(test_module,
                                            checker=doctestOutputChecker,
                                            runner=DocTestRunner)
                if len(test._tests) > 0:
                    suite.addTests(test._tests)
            except ValueError:
                # No doc tests in tests.py
                pass
    return suite
Example #4
0
def suite():

    #testcases = [PledgeTest, AuthorizeTest, TransactionTest]
    testcases = [TransactionTest, CreditTest, AccountTest]
    suites = unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(testcase) for testcase in testcases])
    return suites    
        
       
Example #5
0
def load_test_suite(package_name):
    suite = unittest.TestSuite()
    loader = unittest.TestLoader()

    for test in loader.discover(package_name):
        suite.addTest(test)

    return lambda: suite
Example #6
0
def suite():
    loader = unittest.TestLoader()
    s = unittest.TestSuite()

    for ver in (
            "1.0",
            "1.1",
    ):
        # for ver in ("1.1", ):
        module = import_module('film20.api.api_%s.tests' %
                               ver.replace(".", "_"))
        s.addTests(loader.loadTestsFromModule(module))

    s.addTests(loader.loadTestsFromModule(test_oauth))

    return s
Example #7
0
def suite():
    import glob
    from os.path import dirname, basename, splitext, sep
    from django.utils import unittest


    suite = unittest.TestSuite()

    # find all test files in this directory
    for test_file in glob.glob(dirname(__file__) + sep + 'test_*.py'):

        # get filename without '.py' of test file
        test_name = splitext(basename(test_file))[0]

        # calculate module name of test file
        test_module = __name__ + '.' + test_name

        # add all tests from test file to our test suite
        suite.addTest(unittest.TestLoader().loadTestsFromName(test_module))
    return suite
Example #8
0
 def handle(self, *args, **options):
     apps = []
     if not len(args):
         args = settings.INSTALLED_APPS
     for arg in args:
         try:
             module = __import__(arg)
             filename = inspect.getfile(module)
             top_dir = os.path.abspath(
                 os.path.join(os.path.dirname(filename), '..'))
         except:
             continue
         loader = unittest.TestLoader()
         suite = loader.discover(
             start_dir=arg,
             pattern=r'*.py',
             top_level_dir=top_dir,
         )
         while len(suite._tests):
             obj = suite._tests.pop(0)
             if isinstance(obj, unittest.TestSuite):
                 suite._tests.append(obj._tests)
             elif isinstance(obj, list):
                 if len(obj):
                     suite._tests.extend(obj)
             else:
                 l = obj.__module__.split('.')
                 while l:
                     app = '.'.join(l)
                     del l[-1]
                     try:
                         __import__('.'.join([app, 'models']))
                     except ImportError:
                         continue
                     apps.append(app)
     apps = list(set(apps))
     for app in settings.INSTALLED_APPS:
         if app in apps:
             apps.remove(app)
     apps.sort()
     print "\n".join(apps)
Example #9
0
def suite():
    return unittest.TestSuite(
        (unittest.TestLoader().loadTestsFromTestCase(test_basic.BasicTest), ))
Example #10
0
def TheTestSuite():
    return unittest.TestLoader().loadTestsFromTestCase(TestUserProfile)
Example #11
0
def suite():
    
    suite = unittest.TestLoader().loadTestsFromTestCase(BiostarModelTest)
    
    return suite
Example #12
0
#!/usr/bin/env python
import os
import sys

import django
from django.test.utils import setup_test_environment
from django.utils import unittest

os.environ['DJANGO_SETTINGS_MODULE'] = 'WhatManager2.settings'

if __name__ == '__main__':
    setup_test_environment()
    django.setup()

    suite = unittest.TestLoader().discover('integration_tests')
    result = unittest.TextTestRunner(verbosity=2).run(suite)
    sys.exit(not result.wasSuccessful())
def suite():
    return unittest.TestSuite((unittest.TestLoader().discover(
        start_dir=os.path.abspath(os.path.dirname(__file__)),
        top_level_dir=os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..', '..', '..')),
    ), ))
Example #14
0
        clean_whitelist()

    def testW2(self):
        self.assertAuthenticated('*****@*****.**', 'qwerty')
        for i in xrange(5):
            self.assertAllowed('*****@*****.**')
        self.assertRejected('*****@*****.**')
        clean_whitelist()

    def testW3(self):
        self.assertAuthenticated('*****@*****.**', 'qwerty')
        for i in xrange(4):
            self.assertAllowed('*****@*****.**')
        for i in xrange(7):
            self.assertAuthenticated('*****@*****.**',
                                     'qwerty',
                                     ip='127.0.0.%d' % (2 + i))
        self.assertAllowed('*****@*****.**')
        self.assertRejected('*****@*****.**')
        clean_whitelist()


if __name__ == '__main__':
    if getattr(settings, 'RS_TEST_WHITELIST_AS_WELL', False):
        unittest.main(verbosity=2)
    else:
        suite = unittest.TestLoader().loadTestsFromTestCase(Test)
        unittest.TextTestRunner(verbosity=2).run(suite)
        print '\nWarning: to speed things up whitelist testing was skipped (so that only test redis db is used). '\
              'Run \'./manage.py test redissentry\' to go through all tests (test main database will be used as well).'
Example #15
0
def changes_suite():
    suite = TestSuite()
    suite.addTest(
        unittest.TestLoader().loadTestsFromTestCase(ChangesMixinTest))
    return suite
Example #16
0
 def suite():
     return unittest.TestLoader().discover("testapp", pattern="test_*.py")
Example #17
0
 def handle_noargs(self, **options):
     suite = unittest.TestLoader().loadTestsFromTestCase(AHJUrlsTestCase)
     unittest.TextTestRunner().run(suite)
Example #18
0
def TheTestSuite():
    return unittest.TestLoader().loadTestsFromTestCase(TestSignupForm)
Example #19
0
def TheTestSuite():
    return unittest.TestLoader().loadTestsFromTestCase(TestAdultBirthDateField)
Example #20
0
def suite():
    suite = unittest.TestLoader()
    tests = suite.discover(os.path.dirname(__file__), pattern='test_*.py')
    return tests
Example #21
0
def build_test(label):
    """
    Construct a test case with the specified label. Label should be of the
    form model.TestClass or model.TestClass.test_method. Returns an
    instantiated test or test suite corresponding to the label provided.

    """
    parts = label.split('.')
    if len(parts) < 2 or len(parts) > 3:
        raise ValueError("Test label '%s' should be of the form app.TestCase "
                         "or app.TestCase.test_method" % label)

    #
    # First, look for TestCase instances with a name that matches
    #
    app_module = get_app(parts[0])
    test_module = get_tests(app_module)
    TestClass = getattr(app_module, parts[1], None)

    # Couldn't find the test class in models.py; look in tests.py
    if TestClass is None:
        if test_module:
            TestClass = getattr(test_module, parts[1], None)

    try:
        if issubclass(TestClass, (unittest.TestCase, real_unittest.TestCase)):
            if len(parts) == 2:  # label is app.TestClass
                try:
                    return unittest.TestLoader().loadTestsFromTestCase(
                        TestClass)
                except TypeError:
                    raise ValueError(
                        "Test label '%s' does not refer to a test class" %
                        label)
            else:  # label is app.TestClass.test_method
                return TestClass(parts[2])
    except TypeError:
        # TestClass isn't a TestClass - it must be a method or normal class
        pass

    #
    # If there isn't a TestCase, look for a doctest that matches
    #
    tests = []
    for module in app_module, test_module:
        try:
            doctests = doctest.DocTestSuite(module,
                                            checker=doctestOutputChecker,
                                            runner=DocTestRunner)
            # Now iterate over the suite, looking for doctests whose name
            # matches the pattern that was given
            for test in doctests:
                if test._dt_test.name in (
                        '%s.%s' % (module.__name__, '.'.join(parts[1:])),
                        '%s.__test__.%s' %
                    (module.__name__, '.'.join(parts[1:]))):
                    tests.append(test)
        except ValueError:
            # No doctests found.
            pass

    # If no tests were found, then we were given a bad test label.
    if not tests:
        raise ValueError("Test label '%s' does not refer to a test" % label)

    # Construct a suite out of the tests that matched.
    return unittest.TestSuite(tests)
Example #22
0
def TheTestSuite():
    return unittest.TestLoader().loadTestsFromTestCase(TestSelenium)