1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix var precedence check to support python 3. (#23552)

* Fix var precedence check to support python 3.
* Run CI sanity tests using python 3.5.
* Disable pylint non-iterator-returned test to pass on python 3.5.
This commit is contained in:
Matt Clay 2017-04-13 00:07:40 -07:00 committed by GitHub
parent 442768c45e
commit e7bb508ad6
3 changed files with 19 additions and 18 deletions

View file

@ -59,7 +59,7 @@ class Role(object):
if not os.path.isdir(fpath): if not os.path.isdir(fpath):
os.makedirs(fpath) os.makedirs(fpath)
fname = os.path.join(fpath, 'main.yml') fname = os.path.join(fpath, 'main.yml')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: %s\n' % self.name) f.write('findme: %s\n' % self.name)
if self.vars: if self.vars:
@ -68,7 +68,7 @@ class Role(object):
if not os.path.isdir(fpath): if not os.path.isdir(fpath):
os.makedirs(fpath) os.makedirs(fpath)
fname = os.path.join(fpath, 'main.yml') fname = os.path.join(fpath, 'main.yml')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: %s\n' % self.name) f.write('findme: %s\n' % self.name)
if self.dependencies: if self.dependencies:
@ -76,7 +76,7 @@ class Role(object):
if not os.path.isdir(fpath): if not os.path.isdir(fpath):
os.makedirs(fpath) os.makedirs(fpath)
fname = os.path.join(fpath, 'main.yml') fname = os.path.join(fpath, 'main.yml')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('dependencies:\n') f.write('dependencies:\n')
for dep in self.dependencies: for dep in self.dependencies:
f.write('- { role: %s }\n' % dep) f.write('- { role: %s }\n' % dep)
@ -152,7 +152,7 @@ print(json.dumps(data, indent=2, sort_keys=True))
data = json.dumps(self.inventory) data = json.dumps(self.inventory)
t = self.ENV.from_string(self.BASESCRIPT) t = self.ENV.from_string(self.BASESCRIPT)
fdata = t.render(data=data) fdata = t.render(data=data)
with open(fpath, 'wb') as f: with open(fpath, 'w') as f:
f.write(fdata + '\n') f.write(fdata + '\n')
st = os.stat(fpath) st = os.stat(fpath)
os.chmod(fpath, st.st_mode | stat.S_IEXEC) os.chmod(fpath, st.st_mode | stat.S_IEXEC)
@ -191,7 +191,7 @@ class VarTestMaker(object):
if self.tasks: if self.tasks:
pb_copy['tasks'] = self.tasks pb_copy['tasks'] = self.tasks
with open(fname, 'wb') as f: with open(fname, 'w') as f:
pb_yaml = yaml.dump([pb_copy], f, default_flow_style=False, indent=2) pb_yaml = yaml.dump([pb_copy], f, default_flow_style=False, indent=2)
def build(self): def build(self):
@ -239,7 +239,7 @@ class VarTestMaker(object):
if not os.path.isdir(ipath): if not os.path.isdir(ipath):
os.makedirs(ipath) os.makedirs(ipath)
with open(invfile, 'wb') as f: with open(invfile, 'w') as f:
f.write(self.inventory) f.write(self.inventory)
hpath = os.path.join(TESTDIR, 'inventory', 'host_vars') hpath = os.path.join(TESTDIR, 'inventory', 'host_vars')
@ -251,49 +251,49 @@ class VarTestMaker(object):
if 'ini_host_vars_file' in self.features: if 'ini_host_vars_file' in self.features:
hfile = os.path.join(hpath, 'testhost') hfile = os.path.join(hpath, 'testhost')
with open(hfile, 'wb') as f: with open(hfile, 'w') as f:
f.write('findme: ini_host_vars_file\n') f.write('findme: ini_host_vars_file\n')
if 'ini_group_vars_file_all' in self.features: if 'ini_group_vars_file_all' in self.features:
hfile = os.path.join(gpath, 'all') hfile = os.path.join(gpath, 'all')
with open(hfile, 'wb') as f: with open(hfile, 'w') as f:
f.write('findme: ini_group_vars_file_all\n') f.write('findme: ini_group_vars_file_all\n')
if 'ini_group_vars_file_child' in self.features: if 'ini_group_vars_file_child' in self.features:
hfile = os.path.join(gpath, 'child') hfile = os.path.join(gpath, 'child')
with open(hfile, 'wb') as f: with open(hfile, 'w') as f:
f.write('findme: ini_group_vars_file_child\n') f.write('findme: ini_group_vars_file_child\n')
if 'ini_group_vars_file_parent' in self.features: if 'ini_group_vars_file_parent' in self.features:
hfile = os.path.join(gpath, 'parent') hfile = os.path.join(gpath, 'parent')
with open(hfile, 'wb') as f: with open(hfile, 'w') as f:
f.write('findme: ini_group_vars_file_parent\n') f.write('findme: ini_group_vars_file_parent\n')
if 'pb_host_vars_file' in self.features: if 'pb_host_vars_file' in self.features:
os.makedirs(os.path.join(TESTDIR, 'host_vars')) os.makedirs(os.path.join(TESTDIR, 'host_vars'))
fname = os.path.join(TESTDIR, 'host_vars', 'testhost') fname = os.path.join(TESTDIR, 'host_vars', 'testhost')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: pb_host_vars_file\n') f.write('findme: pb_host_vars_file\n')
if 'pb_group_vars_file_parent' in self.features: if 'pb_group_vars_file_parent' in self.features:
if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')): if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')):
os.makedirs(os.path.join(TESTDIR, 'group_vars')) os.makedirs(os.path.join(TESTDIR, 'group_vars'))
fname = os.path.join(TESTDIR, 'group_vars', 'parent') fname = os.path.join(TESTDIR, 'group_vars', 'parent')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: pb_group_vars_file_parent\n') f.write('findme: pb_group_vars_file_parent\n')
if 'pb_group_vars_file_child' in self.features: if 'pb_group_vars_file_child' in self.features:
if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')): if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')):
os.makedirs(os.path.join(TESTDIR, 'group_vars')) os.makedirs(os.path.join(TESTDIR, 'group_vars'))
fname = os.path.join(TESTDIR, 'group_vars', 'child') fname = os.path.join(TESTDIR, 'group_vars', 'child')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: pb_group_vars_file_child\n') f.write('findme: pb_group_vars_file_child\n')
if 'pb_group_vars_file_all' in self.features: if 'pb_group_vars_file_all' in self.features:
if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')): if not os.path.isdir(os.path.join(TESTDIR, 'group_vars')):
os.makedirs(os.path.join(TESTDIR, 'group_vars')) os.makedirs(os.path.join(TESTDIR, 'group_vars'))
fname = os.path.join(TESTDIR, 'group_vars', 'all') fname = os.path.join(TESTDIR, 'group_vars', 'all')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: pb_group_vars_file_all\n') f.write('findme: pb_group_vars_file_all\n')
if 'play_var' in self.features: if 'play_var' in self.features:
@ -305,13 +305,13 @@ class VarTestMaker(object):
if 'vars_file' in self.features: if 'vars_file' in self.features:
self.varsfiles.append('varsfile.yml') self.varsfiles.append('varsfile.yml')
fname = os.path.join(TESTDIR, 'varsfile.yml') fname = os.path.join(TESTDIR, 'varsfile.yml')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: vars_file\n') f.write('findme: vars_file\n')
if 'include_vars' in self.features: if 'include_vars' in self.features:
self.tasks.append(dict(include_vars='included_vars.yml')) self.tasks.append(dict(include_vars='included_vars.yml'))
fname = os.path.join(TESTDIR, 'included_vars.yml') fname = os.path.join(TESTDIR, 'included_vars.yml')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write('findme: include_vars\n') f.write('findme: include_vars\n')
if 'role_var' in self.features: if 'role_var' in self.features:
@ -366,7 +366,7 @@ class VarTestMaker(object):
self.tasks.append(dict(include='included_tasks.yml')) self.tasks.append(dict(include='included_tasks.yml'))
fname = os.path.join(TESTDIR, 'included_tasks.yml') fname = os.path.join(TESTDIR, 'included_tasks.yml')
with open(fname, 'wb') as f: with open(fname, 'w') as f:
f.write(yaml.dump(block_wrapper)) f.write(yaml.dump(block_wrapper))
self.write_playbook() self.write_playbook()

View file

@ -9,6 +9,7 @@ method-hidden
no-member no-member
no-name-in-module no-name-in-module
no-value-for-parameter no-value-for-parameter
non-iterator-returned
not-a-mapping not-a-mapping
not-an-iterable not-an-iterable
not-callable not-callable

View file

@ -19,7 +19,7 @@ retry.py pip install tox --disable-pip-version-check
echo '{"verified": false, "results": []}' > test/results/bot/ansible-test-failure.json echo '{"verified": false, "results": []}' > test/results/bot/ansible-test-failure.json
ansible-test compile --failure-ok --color -v --junit --requirements ansible-test compile --failure-ok --color -v --junit --requirements
ansible-test sanity --failure-ok --color -v --junit --tox --skip-test ansible-doc --python 2.7 ansible-test sanity --failure-ok --color -v --junit --tox --skip-test ansible-doc --python 3.5
ansible-test sanity --failure-ok --color -v --junit --tox --test ansible-doc --coverage ansible-test sanity --failure-ok --color -v --junit --tox --test ansible-doc --coverage
rm test/results/bot/ansible-test-failure.json rm test/results/bot/ansible-test-failure.json