mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Move helper outside of for loop
This commit is contained in:
parent
3f1b6fd661
commit
a97e0320bf
1 changed files with 12 additions and 12 deletions
|
@ -390,6 +390,18 @@ class SaltTestingParser(optparse.OptionParser):
|
|||
else:
|
||||
filename_map = {}
|
||||
|
||||
def _add(comps):
|
||||
'''
|
||||
Helper to add unit and integration tests matching a given mod path
|
||||
'''
|
||||
mod_relname = '.'.join(comps)
|
||||
ret.update(
|
||||
x for x in
|
||||
['.'.join(('unit', mod_relname)),
|
||||
'.'.join(('integration', mod_relname))]
|
||||
if x in self._test_mods
|
||||
)
|
||||
|
||||
# First, try a path match
|
||||
for path in files:
|
||||
match = re.match(r'^(salt/|tests/(integration|unit)/)(.+\.py)$', path)
|
||||
|
@ -404,15 +416,6 @@ class SaltTestingParser(optparse.OptionParser):
|
|||
else:
|
||||
comps[-1] = 'test_{0}'.format(comps[-1][:-3])
|
||||
|
||||
candidates = []
|
||||
|
||||
def _add(comps):
|
||||
mod_relname = '.'.join(comps)
|
||||
candidates.extend(
|
||||
['.'.join(('unit', mod_relname)),
|
||||
'.'.join(('integration', mod_relname))]
|
||||
)
|
||||
|
||||
# Direct name matches
|
||||
_add(comps)
|
||||
|
||||
|
@ -423,9 +426,6 @@ class SaltTestingParser(optparse.OptionParser):
|
|||
comps[-2] = 'states'
|
||||
_add(comps)
|
||||
|
||||
# Add any candidates for which test modules exist
|
||||
ret.update([x for x in candidates if x in self._test_mods])
|
||||
|
||||
# Make sure to run a test module if it's been modified
|
||||
elif match.group(1).startswith('tests/'):
|
||||
comps.insert(0, match.group(2))
|
||||
|
|
Loading…
Add table
Reference in a new issue