Example #1
0
def run_tests(names, verbosity=1):
    """Run unittests for all the test names.

    A name can be either a package name or a fully qualified name of the
    test class or a specific test method within a package prefixed with
    ``package_name:``.

    For example:

        >>> run_tests('hello')
        >>> run_tests('hello:HelloTest')
        >>> run_tests('hello:HelloTest.test_hello')
        >>> run_tests('foo:foo.FooTest')
        >>> run_tests('foo:bar.BarTest')

    :param names: a sequence of names
    :param verbosity: verbose level
    """

    from kalapy.core.pool import pool
    from kalapy.db.engines import database

    database.connect()
    try:
        # Initialize the object pool
        pool.load()
        suite = unittest.TestSuite()
        for name in names:
            suite.addTest(build_suite(name))
        result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
    finally:
        database.close()

    return len(result.failures) + len(result.errors)
Example #2
0
File: db.py Project: lafada/kalapy
    def execute(self, options, args):

        if settings.DATABASE_ENGINE == "dummy":
            raise self.error("DATABASE_ENGINE is not configured.")

        database.connect()
        try:
            # load packages
            loader.load()
            super(DBCommand, self).execute(options, args)
        finally:
            database.close()
Example #3
0
    def execute(self, options, args):

        if settings.DATABASE_ENGINE == "dummy":
            raise self.error("DATABASE_ENGINE is not configured.")

        try:
            database.connect()
            try:
                # Initialize the object pool
                from kalapy.core.pool import pool
                pool.load()
                super(DBCommand, self).execute(options, args)
            finally:
                database.close()
        except db.DatabaseError, e:
            self.error(e)