mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
Move the v2 tests under the v2 tree
This commit is contained in:
parent
187da236b4
commit
938b2108d0
16 changed files with 25 additions and 515 deletions
|
@ -18,7 +18,12 @@
|
|||
import os
|
||||
import pwd
|
||||
import sys
|
||||
import ConfigParser
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
# Python 2.7
|
||||
import ConfigParser as configparser
|
||||
|
||||
from string import ascii_letters, digits
|
||||
|
||||
# copied from utils, avoid circular reference fun :)
|
||||
|
@ -60,7 +65,7 @@ def _get_config(p, section, key, env_var, default):
|
|||
def load_config_file():
|
||||
''' Load Config File order(first found is used): ENV, CWD, HOME, /etc/ansible '''
|
||||
|
||||
p = ConfigParser.ConfigParser()
|
||||
p = configparser.ConfigParser()
|
||||
|
||||
path0 = os.getenv("ANSIBLE_CONFIG", None)
|
||||
if path0 is not None:
|
||||
|
@ -73,8 +78,8 @@ def load_config_file():
|
|||
if path is not None and os.path.exists(path):
|
||||
try:
|
||||
p.read(path)
|
||||
except ConfigParser.Error as e:
|
||||
print "Error reading config file: \n%s" % e
|
||||
except configparser.Error as e:
|
||||
print("Error reading config file: \n{0}".format(e))
|
||||
sys.exit(1)
|
||||
return p
|
||||
return None
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import exceptions
|
||||
from six import iteritems, string_types
|
||||
|
||||
from ansible.errors import AnsibleParserError
|
||||
from ansible.plugins import module_finder
|
||||
|
@ -141,7 +141,7 @@ class ModuleArgsParser(object):
|
|||
if isinstance(thing, dict):
|
||||
# form is like: local_action: { module: 'xyz', x: 2, y: 3 } ... uncommon!
|
||||
args = thing
|
||||
elif isinstance(thing, basestring):
|
||||
elif isinstance(thing, string_types):
|
||||
# form is like: local_action: copy src=a dest=b ... pretty common
|
||||
args = parse_kv(thing)
|
||||
else:
|
||||
|
@ -173,7 +173,7 @@ class ModuleArgsParser(object):
|
|||
args = thing.copy()
|
||||
del args['module']
|
||||
|
||||
elif isinstance(thing, basestring):
|
||||
elif isinstance(thing, string_types):
|
||||
# form is like: copy: src=a dest=b ... common shorthand throughout ansible
|
||||
(action, args) = self._split_module_string(thing)
|
||||
args = parse_kv(args)
|
||||
|
@ -222,7 +222,7 @@ class ModuleArgsParser(object):
|
|||
raise AnsibleParserError("conflicting action statements", obj=self._task)
|
||||
|
||||
# walk the input dictionary to see we recognize a module name
|
||||
for (item, value) in ds.iteritems():
|
||||
for (item, value) in iteritems(ds):
|
||||
if item in module_finder:
|
||||
# finding more than one module name is a problem
|
||||
if action is not None:
|
||||
|
|
|
@ -27,7 +27,7 @@ def parse_kv(args, check_raw=False):
|
|||
if args is not None:
|
||||
try:
|
||||
vargs = split_args(args)
|
||||
except ValueError, ve:
|
||||
except ValueError as ve:
|
||||
if 'no closing quotation' in str(ve).lower():
|
||||
raise errors.AnsibleError("error parsing argument string, try quoting the entire line.")
|
||||
else:
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from io import FileIO
|
||||
|
||||
from six import iteritems, string_types
|
||||
|
||||
from ansible.playbook.attribute import Attribute, FieldAttribute
|
||||
from ansible.parsing import load as ds_load
|
||||
|
||||
|
@ -25,7 +29,7 @@ class Base(object):
|
|||
# each class knows attributes set upon it, see Task.py for example
|
||||
self._attributes = dict()
|
||||
|
||||
for (name, value) in self.__class__.__dict__.iteritems():
|
||||
for (name, value) in iteritems(self.__class__.__dict__):
|
||||
aname = name[1:]
|
||||
if isinstance(value, Attribute):
|
||||
self._attributes[aname] = value.default
|
||||
|
@ -40,7 +44,7 @@ class Base(object):
|
|||
|
||||
assert ds is not None
|
||||
|
||||
if isinstance(ds, basestring) or isinstance(ds, file):
|
||||
if isinstance(ds, string_types) or isinstance(ds, FileIO):
|
||||
ds = ds_load(ds)
|
||||
|
||||
# we currently don't do anything with private attributes but may
|
||||
|
@ -49,7 +53,7 @@ class Base(object):
|
|||
ds = self.munge(ds)
|
||||
|
||||
# walk all attributes in the class
|
||||
for (name, attribute) in self.__class__.__dict__.iteritems():
|
||||
for (name, attribute) in iteritems(self.__class__.__dict__):
|
||||
aname = name[1:]
|
||||
|
||||
# process Field attributes which get loaded from the YAML
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue