Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _find_tests_in_file(self, event, filename, full_path, top_level, module_name=None):
log.debug("find in file %s (%s)", full_path, top_level)
pattern = self.session.testFilePattern
loader = event.loader
evt = events.HandleFileEvent(
loader, filename, full_path, pattern, top_level)
result = self.session.hooks.handleFile(evt)
if evt.extraTests:
yield loader.suiteClass(evt.extraTests)
if evt.handled:
if result:
yield result
return
if not util.valid_module_name(filename):
# valid Python identifiers only
return
evt = events.MatchPathEvent(filename, full_path, pattern)
result = self.session.hooks.matchPath(evt)
if evt.handled:
if not result:
return
elif not self._match_path(filename, full_path, pattern):
return
if module_name is None:
module_name, package_path = util.name_from_path(full_path)
util.ensure_importable(package_path)
try:
module = util.module_from_name(module_name)
def run(self):
plugin_name = self.arguments[0]
parent, plugin = util.object_from_name(plugin_name)
if isinstance(plugin, types.ModuleType):
# document all plugins in module
module = plugin
mod_name = module.__name__
plugins = self.plugins(module)
else:
if 'module' in self.options:
mod_name = self.options['module']
else:
mod_name = plugin_name[
0:plugin_name.index(plugin.__name__) - 1]
plugins = [plugin]
rst = ViewList()
if mod_name:
def _inLayer(self, layer, test, method):
meth = self._getBoundClassmethod(layer, method)
if meth:
if util.num_expected_args(meth) > 1:
meth(test)
else:
meth()