forked from vmware-archive/salt-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrib.py
32 lines (24 loc) · 860 Bytes
/
contrib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from salttesting import TestSuite, TestLoader
import os
tests = TestSuite()
loader = TestLoader()
# add some useful tests from the main suite
extra = ('integration.modules.sysmod', )
tests.addTest(loader.loadTestsFromNames(extra))
# this should resolve to the salt-contrib directory
# need to check if we are compiled or not!
current_file = __file__
if current_file[-4:] == '.pyc':
current_file = current_file[:-1]
current_dir = os.path.dirname(os.path.realpath(current_file))
l = len(current_dir)
names = []
for dirname, dirs, files in os.walk(current_dir):
parts = dirname[l:].split(os.sep)
if len(parts) < 2:
continue
module = '.'.join(parts[1:])
for f in files:
if f[-3:] == '.py' and f != '__init__.py':
names.append('{0}.{1}'.format(module, f[:-3]))
tests.addTest(loader.loadTestsFromNames(names))