示例#1
0
def run_one(case, test):
    """
    :param path case:

       The path to a specific :term:`case` (i.e. Python module,)
       relative to the current working directory.

    :param path test:

       The path to a single :term:`test` (i.e. a test definition in
       YAML format,) relative to the current working directory.

    Use :meth:`run_one()` to run a single, specific ``dtf`` test.
    """
    logger.debug('creating case definition object.')
    dfn = SingleCaseDefinition()

    logger.debug('loading case {0}.'.format(case))
    dfn.load(case)
    logger.debug('loaded {0} case.'.format(case))

    logger.info('configuring test runner object.')
    t = SingleTestRunner()
    logger.debug('loading test {0}.'.format(test))
    t.load(test)
    logger.debug('test {0} successfully loaded.'.format(test))
    logger.info('test runner object configured.')

    logger.debug('passing case definitions to test runner.')
    t.definitions(dfn.cases)
    logger.debug('test runner ready to .')

    logger.debug('starting test run.')
    t.run(get_name(case))
    logger.debug('test run complete.')
示例#2
0
    def _load(self, spec):
        """
        :param spec: The filename of a test spec.

        An internal function to load a test function into the
        :attr:`~core.TestRunner.test_specs` and
        :attr:`:attr:`~core.TestRunner.queue` attributes of the
        :class:`~core.TestRunner` object.
        """
        with open(spec) as f:
            test = get_name(spec)
            specs = yaml.load_all(f)

            for spec in specs:
                self.test_specs.update( { test: spec } )
                self._add_to_queue(test, spec['type'])
                logger.debug('added {0} to TestRunner test queue'.format(test))
示例#3
0
    def _add(self, f, path=None):
        """
        :param f: A file name that contains the path name to
                  :meth:`_add()` provides no validation of this
                  module.

        :param path: Defaults to ``None``. If specified, this becomes
                     the path that :mod:`dtf` uses as the base path to
                     import the module.

        An internal method used to add a single case definition to a
        :class:`~core.CaseDefinition` object's
        :attr:`~core.CaseDefinition.modules` attribute. Typically
        :class:`~core.CaseDefinition` sub-classes'
        :meth:`~core.CaseDefinition.add()` methods will wrap
        :meth:`~core.CaseDefinition._add()`.
        """

        if path is None:
            path = os.path.dirname(f)

        self.modules.update({get_name(f): path})
        logger.debug('added file {0} to '.format(f))