Esempio n. 1
0
    def _iter_paths(self, paths):

        paths = list(paths)
        for path in paths:
            if not os.path.exists(path):
                msg = "Path {!r} could not be found".format(path)
                with handling_exceptions():
                    raise CannotLoadTests(msg)
        for path in paths:
            for file_path in _walk(path):
                _logger.debug("Checking {0}", file_path)
                if not self._is_file_wanted(file_path):
                    _logger.debug("{0} is not wanted. Skipping...", file_path)
                    continue
                module = None
                try:
                    with handling_exceptions(context="during import"):
                        if not config.root.run.message_assertion_introspection:
                            dessert.disable_message_introspection()
                        with dessert.rewrite_assertions_context():
                            module = import_file(file_path)
                except Exception as e:

                    tb_file, tb_lineno, _, _ = _extract_tb()
                    raise mark_exception_handled(
                        CannotLoadTests(
                            "Could not load {0!r} ({1}:{2} - {3})".format(file_path, tb_file, tb_lineno, e)))
                if module is not None:
                    self._duplicate_funcs |= check_duplicate_functions(file_path)
                    with self._adding_local_fixtures(file_path, module):
                        for runnable in self._iter_runnable_tests_in_module(file_path, module):
                            if self._is_excluded(runnable):
                                continue
                            yield runnable
Esempio n. 2
0
def _disable_introspection():
    dessert.disable_message_introspection()
    try:
        yield
    finally:
        dessert.enable_message_introspection()
Esempio n. 3
0
def _disable_introspection():
    dessert.disable_message_introspection()
    try:
        yield
    finally:
        dessert.enable_message_introspection()