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.db.engines import database
    from kalapy.conf.loader import loader

    database.connect()
    try:
        loader.load() # load all packages
        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
    def __init__(self):

        # load all the settings.INSTALLED_PACKAGES
        from kalapy.conf.loader import loader
        loader.load()

        super(Application, self).__init__(
                settings.PROJECT_NAME,
                settings.PROJECT_DIR)

        self.debug = settings.DEBUG
        _local.current_app = self

        #: list of all the registered middlewares
        self.middlewares = []

        # register all the settings.MIDDLEWARE_CLASSES
        for mc in settings.MIDDLEWARE_CLASSES:
            mc = import_string(mc)
            self.middlewares.append(mc())

        # static data middleware
        static_dirs = [p.static for p in Package.ALL.values() if p.static]
        if self.static:
            static_dirs.append(self.static)
        self.dispatch = SharedDataMiddleware(self.dispatch, dict(static_dirs))
Example #3
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 #4
0
    def execute(self, options, args):
        try:
            script = args[0]
        except:
            self.print_help()

        if not os.path.exists(script):
            self.error("%r doesn't exist." % script)

        # load the packages
        from kalapy.conf.loader import loader

        loader.load()

        execfile(script, {"__name__": "__main__"})
Example #5
0
    def execute(self, options, args):

        # load the packages
        from kalapy.conf.loader import loader

        loader.load()

        imported_objects = {}
        try:  # Try activating rlcompleter, because it's handy.
            import readline
            import rlcompleter

            readline.set_completer(rlcompleter.Completer(imported_objects).complete)
            readline.parse_and_bind("tab:complete")
        except ImportError:
            pass

        import code

        code.interact(local=imported_objects)