PEP 8 indent cleanup. (#20800)

* PEP 8 E121 cleanup.

* PEP 8 E126 cleanup.

* PEP 8 E122 cleanup.
This commit is contained in:
Matt Clay 2017-01-28 23:28:53 -08:00 committed by John R Barker
commit 10d9318de7
244 changed files with 2873 additions and 2973 deletions

View file

@ -1,29 +1,17 @@
contrib/inventory/abiquo.py
contrib/inventory/azure_rm.py
contrib/inventory/cloudstack.py
contrib/inventory/consul_io.py
contrib/inventory/digital_ocean.py
contrib/inventory/docker.py
contrib/inventory/ec2.py
contrib/inventory/gce.py
contrib/inventory/mdt_dynamic_inventory.py
contrib/inventory/openvz.py
contrib/inventory/rax.py
contrib/inventory/softlayer.py
contrib/inventory/ssh_config.py
contrib/inventory/vbox.py
contrib/inventory/zone.py
docs/api/conf.py
docs/docsite/conf.py
docs/docsite/rst/conf.py
docs/docsite/rst/dev_guide/conf.py
examples/scripts/uptime.py
hacking/metadata-tool.py
hacking/module_formatter.py
hacking/tests/gen_distribution_version_testcase.py
lib/ansible/cli/__init__.py
lib/ansible/cli/adhoc.py
lib/ansible/cli/console.py
lib/ansible/cli/galaxy.py
lib/ansible/cli/playbook.py
lib/ansible/compat/six/__init__.py
@ -42,11 +30,8 @@ lib/ansible/module_utils/ec2.py
lib/ansible/module_utils/eos.py
lib/ansible/module_utils/f5.py
lib/ansible/module_utils/facts.py
lib/ansible/module_utils/gcp.py
lib/ansible/module_utils/known_hosts.py
lib/ansible/module_utils/mysql.py
lib/ansible/module_utils/nxos.py
lib/ansible/module_utils/redhat.py
lib/ansible/module_utils/vmware.py
lib/ansible/modules/cloud/amazon/_ec2_vpc.py
lib/ansible/modules/cloud/amazon/aws_kms.py
@ -58,19 +43,15 @@ lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py
lib/ansible/modules/cloud/amazon/dynamodb_table.py
lib/ansible/modules/cloud/amazon/ec2.py
lib/ansible/modules/cloud/amazon/ec2_ami.py
lib/ansible/modules/cloud/amazon/ec2_ami_copy.py
lib/ansible/modules/cloud/amazon/ec2_ami_find.py
lib/ansible/modules/cloud/amazon/ec2_asg.py
lib/ansible/modules/cloud/amazon/ec2_asg_facts.py
lib/ansible/modules/cloud/amazon/ec2_customer_gateway.py
lib/ansible/modules/cloud/amazon/ec2_elb.py
lib/ansible/modules/cloud/amazon/ec2_elb_facts.py
lib/ansible/modules/cloud/amazon/ec2_elb_lb.py
lib/ansible/modules/cloud/amazon/ec2_eni.py
lib/ansible/modules/cloud/amazon/ec2_eni_facts.py
lib/ansible/modules/cloud/amazon/ec2_facts.py
lib/ansible/modules/cloud/amazon/ec2_group.py
lib/ansible/modules/cloud/amazon/ec2_key.py
lib/ansible/modules/cloud/amazon/ec2_lc.py
lib/ansible/modules/cloud/amazon/ec2_lc_facts.py
lib/ansible/modules/cloud/amazon/ec2_metric_alarm.py
@ -87,7 +68,6 @@ lib/ansible/modules/cloud/amazon/ec2_vpc_net.py
lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py
lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
@ -97,7 +77,6 @@ lib/ansible/modules/cloud/amazon/ecs_service_facts.py
lib/ansible/modules/cloud/amazon/ecs_task.py
lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py
lib/ansible/modules/cloud/amazon/elasticache.py
lib/ansible/modules/cloud/amazon/elasticache_subnet_group.py
lib/ansible/modules/cloud/amazon/iam.py
lib/ansible/modules/cloud/amazon/iam_cert.py
lib/ansible/modules/cloud/amazon/iam_policy.py
@ -109,7 +88,6 @@ lib/ansible/modules/cloud/amazon/rds_subnet_group.py
lib/ansible/modules/cloud/amazon/redshift.py
lib/ansible/modules/cloud/amazon/route53.py
lib/ansible/modules/cloud/amazon/route53_health_check.py
lib/ansible/modules/cloud/amazon/route53_zone.py
lib/ansible/modules/cloud/amazon/s3.py
lib/ansible/modules/cloud/amazon/s3_bucket.py
lib/ansible/modules/cloud/amazon/s3_lifecycle.py
@ -118,8 +96,6 @@ lib/ansible/modules/cloud/amazon/s3_website.py
lib/ansible/modules/cloud/amazon/sns_topic.py
lib/ansible/modules/cloud/amazon/sts_assume_role.py
lib/ansible/modules/cloud/amazon/sts_session_token.py
lib/ansible/modules/cloud/atomic/atomic_host.py
lib/ansible/modules/cloud/atomic/atomic_image.py
lib/ansible/modules/cloud/azure/azure.py
lib/ansible/modules/cloud/azure/azure_rm_deployment.py
lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py
@ -135,46 +111,26 @@ lib/ansible/modules/cloud/cloudstack/cs_host.py
lib/ansible/modules/cloud/cloudstack/cs_instance.py
lib/ansible/modules/cloud/cloudstack/cs_iso.py
lib/ansible/modules/cloud/cloudstack/cs_portforward.py
lib/ansible/modules/cloud/cloudstack/cs_securitygroup_rule.py
lib/ansible/modules/cloud/cloudstack/cs_sshkeypair.py
lib/ansible/modules/cloud/digital_ocean/digital_ocean.py
lib/ansible/modules/cloud/docker/_docker.py
lib/ansible/modules/cloud/docker/docker_container.py
lib/ansible/modules/cloud/docker/docker_image.py
lib/ansible/modules/cloud/docker/docker_service.py
lib/ansible/modules/cloud/google/gc_storage.py
lib/ansible/modules/cloud/google/gce_img.py
lib/ansible/modules/cloud/google/gce_lb.py
lib/ansible/modules/cloud/google/gce_mig.py
lib/ansible/modules/cloud/google/gce_net.py
lib/ansible/modules/cloud/google/gce_pd.py
lib/ansible/modules/cloud/google/gce_tag.py
lib/ansible/modules/cloud/google/gcpubsub.py
lib/ansible/modules/cloud/google/gcpubsub_facts.py
lib/ansible/modules/cloud/linode/linode.py
lib/ansible/modules/cloud/misc/ovirt.py
lib/ansible/modules/cloud/misc/proxmox.py
lib/ansible/modules/cloud/misc/proxmox_kvm.py
lib/ansible/modules/cloud/misc/proxmox_template.py
lib/ansible/modules/cloud/misc/serverless.py
lib/ansible/modules/cloud/misc/virt.py
lib/ansible/modules/cloud/misc/xenserver_facts.py
lib/ansible/modules/cloud/openstack/_glance_image.py
lib/ansible/modules/cloud/openstack/_keystone_user.py
lib/ansible/modules/cloud/openstack/_nova_compute.py
lib/ansible/modules/cloud/openstack/_quantum_floating_ip.py
lib/ansible/modules/cloud/openstack/_quantum_floating_ip_associate.py
lib/ansible/modules/cloud/openstack/_quantum_network.py
lib/ansible/modules/cloud/openstack/_quantum_router.py
lib/ansible/modules/cloud/openstack/_quantum_router_gateway.py
lib/ansible/modules/cloud/openstack/_quantum_router_interface.py
lib/ansible/modules/cloud/openstack/_quantum_subnet.py
lib/ansible/modules/cloud/openstack/os_auth.py
lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py
lib/ansible/modules/cloud/openstack/os_object.py
lib/ansible/modules/cloud/openstack/os_quota.py
lib/ansible/modules/cloud/openstack/os_recordset.py
lib/ansible/modules/cloud/openstack/os_zone.py
lib/ansible/modules/cloud/packet/packet_device.py
lib/ansible/modules/cloud/packet/packet_sshkey.py
lib/ansible/modules/cloud/profitbricks/profitbricks.py
@ -182,7 +138,6 @@ lib/ansible/modules/cloud/profitbricks/profitbricks_datacenter.py
lib/ansible/modules/cloud/softlayer/sl_vm.py
lib/ansible/modules/cloud/vmware/vca_fw.py
lib/ansible/modules/cloud/vmware/vmware_guest.py
lib/ansible/modules/cloud/vmware/vmware_local_user_manager.py
lib/ansible/modules/cloud/vmware/vsphere_guest.py
lib/ansible/modules/cloud/webfaction/webfaction_app.py
lib/ansible/modules/cloud/webfaction/webfaction_db.py
@ -190,17 +145,11 @@ lib/ansible/modules/cloud/webfaction/webfaction_domain.py
lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
lib/ansible/modules/cloud/webfaction/webfaction_site.py
lib/ansible/modules/clustering/consul.py
lib/ansible/modules/clustering/consul_acl.py
lib/ansible/modules/clustering/consul_kv.py
lib/ansible/modules/clustering/consul_session.py
lib/ansible/modules/commands/command.py
lib/ansible/modules/commands/script.py
lib/ansible/modules/crypto/openssl_publickey.py
lib/ansible/modules/database/influxdb/influxdb_retention_policy.py
lib/ansible/modules/database/misc/mongodb_parameter.py
lib/ansible/modules/database/misc/mongodb_user.py
lib/ansible/modules/database/misc/redis.py
lib/ansible/modules/database/misc/riak.py
lib/ansible/modules/database/mssql/mssql_db.py
lib/ansible/modules/database/mysql/mysql_db.py
lib/ansible/modules/database/mysql/mysql_replication.py
@ -219,25 +168,17 @@ lib/ansible/modules/files/archive.py
lib/ansible/modules/files/copy.py
lib/ansible/modules/files/find.py
lib/ansible/modules/files/ini_file.py
lib/ansible/modules/files/lineinfile.py
lib/ansible/modules/files/stat.py
lib/ansible/modules/files/synchronize.py
lib/ansible/modules/files/tempfile.py
lib/ansible/modules/files/unarchive.py
lib/ansible/modules/messaging/rabbitmq_binding.py
lib/ansible/modules/messaging/rabbitmq_exchange.py
lib/ansible/modules/messaging/rabbitmq_queue.py
lib/ansible/modules/monitoring/boundary_meter.py
lib/ansible/modules/monitoring/datadog_monitor.py
lib/ansible/modules/monitoring/librato_annotation.py
lib/ansible/modules/monitoring/logicmonitor.py
lib/ansible/modules/monitoring/logicmonitor_facts.py
lib/ansible/modules/monitoring/nagios.py
lib/ansible/modules/monitoring/pagerduty.py
lib/ansible/modules/monitoring/pagerduty_alert.py
lib/ansible/modules/monitoring/pingdom.py
lib/ansible/modules/monitoring/sensu_check.py
lib/ansible/modules/monitoring/statusio_maintenance.py
lib/ansible/modules/monitoring/zabbix_screen.py
lib/ansible/modules/network/a10/a10_server.py
lib/ansible/modules/network/a10/a10_server_axapi3.py
@ -321,28 +262,20 @@ lib/ansible/modules/network/snmp_facts.py
lib/ansible/modules/notification/hall.py
lib/ansible/modules/notification/sendgrid.py
lib/ansible/modules/notification/sns.py
lib/ansible/modules/packaging/language/bundler.py
lib/ansible/modules/packaging/language/composer.py
lib/ansible/modules/packaging/language/cpanm.py
lib/ansible/modules/packaging/language/maven_artifact.py
lib/ansible/modules/packaging/os/apt.py
lib/ansible/modules/packaging/os/apt_key.py
lib/ansible/modules/packaging/os/apt_rpm.py
lib/ansible/modules/packaging/os/dnf.py
lib/ansible/modules/packaging/os/dpkg_selections.py
lib/ansible/modules/packaging/os/homebrew.py
lib/ansible/modules/packaging/os/openbsd_pkg.py
lib/ansible/modules/packaging/os/opkg.py
lib/ansible/modules/packaging/os/pacman.py
lib/ansible/modules/packaging/os/pkgin.py
lib/ansible/modules/packaging/os/pkgng.py
lib/ansible/modules/packaging/os/portinstall.py
lib/ansible/modules/packaging/os/redhat_subscription.py
lib/ansible/modules/packaging/os/rhn_channel.py
lib/ansible/modules/packaging/os/rhn_register.py
lib/ansible/modules/packaging/os/rpm_key.py
lib/ansible/modules/packaging/os/swdepot.py
lib/ansible/modules/packaging/os/urpmi.py
lib/ansible/modules/packaging/os/yum.py
lib/ansible/modules/packaging/os/zypper.py
lib/ansible/modules/remote_management/foreman/katello.py
@ -357,21 +290,15 @@ lib/ansible/modules/storage/netapp/netapp_e_snapshot_group.py
lib/ansible/modules/storage/netapp/netapp_e_snapshot_volume.py
lib/ansible/modules/storage/netapp/netapp_e_storage_system.py
lib/ansible/modules/storage/netapp/netapp_e_storagepool.py
lib/ansible/modules/system/authorized_key.py
lib/ansible/modules/system/cron.py
lib/ansible/modules/system/debconf.py
lib/ansible/modules/system/filesystem.py
lib/ansible/modules/system/firewalld.py
lib/ansible/modules/system/gconftool2.py
lib/ansible/modules/system/gluster_volume.py
lib/ansible/modules/system/group.py
lib/ansible/modules/system/known_hosts.py
lib/ansible/modules/system/locale_gen.py
lib/ansible/modules/system/lvol.py
lib/ansible/modules/system/openwrt_init.py
lib/ansible/modules/system/pam_limits.py
lib/ansible/modules/system/sefcontext.py
lib/ansible/modules/system/seport.py
lib/ansible/modules/system/solaris_zone.py
lib/ansible/modules/system/systemd.py
lib/ansible/modules/system/ufw.py
@ -384,12 +311,10 @@ lib/ansible/modules/utilities/logic/pause.py
lib/ansible/modules/utilities/logic/set_fact.py
lib/ansible/modules/utilities/logic/wait_for.py
lib/ansible/modules/web_infrastructure/apache2_mod_proxy.py
lib/ansible/modules/web_infrastructure/apache2_module.py
lib/ansible/modules/web_infrastructure/django_manage.py
lib/ansible/modules/web_infrastructure/jenkins_job.py
lib/ansible/modules/web_infrastructure/jira.py
lib/ansible/modules/web_infrastructure/nginx_status_facts.py
lib/ansible/modules/web_infrastructure/taiga_issue.py
lib/ansible/modules/windows/win_acl.py
lib/ansible/modules/windows/win_acl_inheritance.py
lib/ansible/modules/windows/win_chocolatey.py
@ -411,7 +336,6 @@ lib/ansible/modules/windows/win_webpicmd.py
lib/ansible/parsing/mod_args.py
lib/ansible/playbook/attribute.py
lib/ansible/playbook/block.py
lib/ansible/playbook/helpers.py
lib/ansible/playbook/play_context.py
lib/ansible/playbook/playbook_include.py
lib/ansible/playbook/role/__init__.py
@ -423,14 +347,10 @@ lib/ansible/plugins/action/async.py
lib/ansible/plugins/action/set_fact.py
lib/ansible/plugins/action/set_stats.py
lib/ansible/plugins/action/synchronize.py
lib/ansible/plugins/action/template.py
lib/ansible/plugins/cache/jsonfile.py
lib/ansible/plugins/callback/default.py
lib/ansible/plugins/callback/dense.py
lib/ansible/plugins/callback/foreman.py
lib/ansible/plugins/callback/logentries.py
lib/ansible/plugins/callback/oneline.py
lib/ansible/plugins/callback/selective.py
lib/ansible/plugins/connection/accelerate.py
lib/ansible/plugins/connection/paramiko_ssh.py
lib/ansible/plugins/connection/ssh.py
@ -466,26 +386,9 @@ test/units/errors/test_errors.py
test/units/executor/test_playbook_executor.py
test/units/mock/yaml_helper.py
test/units/module_utils/basic/test__log_invocation.py
test/units/module_utils/basic/test_exit_json.py
test/units/module_utils/basic/test_log.py
test/units/module_utils/basic/test_no_log.py
test/units/module_utils/basic/test_safe_eval.py
test/units/module_utils/basic/test_set_mode_if_different.py
test/units/module_utils/json_utils/test_filter_non_json_lines.py
test/units/module_utils/test_basic.py
test/units/module_utils/test_distribution_version.py
test/units/module_utils/test_facts.py
test/units/module_utils/test_text.py
test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py
test/units/parsing/test_mod_args.py
test/units/parsing/yaml/test_loader.py
test/units/playbook/test_block.py
test/units/playbook/test_helpers.py
test/units/playbook/test_play_context.py
test/units/playbook/test_task.py
test/units/plugins/lookup/test_ini.py
test/units/plugins/lookup/test_password.py
test/units/template/test_templar.py
test/units/template/test_template_utilities.py
test/units/utils/test_vars.py
test/units/vars/test_variable_manager.py

View file

@ -1,9 +1,6 @@
E111
E114
E121
E122
E125
E126
E129
E501
E712

View file

@ -92,28 +92,28 @@ class TestAnsibleModuleExitJson(unittest.TestCase):
class TestAnsibleModuleExitValuesRemoved(unittest.TestCase):
OMIT = 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
dataset = (
(dict(username='person', password='$ecret k3y'),
(dict(username='person', password='$ecret k3y'),
dict(one=1, pwd='$ecret k3y', url='https://username:password12345@foo.com/login/',
not_secret='following the leader', msg='here'),
dict(one=1, pwd=OMIT, url='https://username:password12345@foo.com/login/',
not_secret='following the leader', changed=False, msg='here',
invocation=dict(module_args=dict(password=OMIT, token=None, username='person'))),
),
(dict(username='person', password='password12345'),
(dict(username='person', password='password12345'),
dict(one=1, pwd='$ecret k3y', url='https://username:password12345@foo.com/login/',
not_secret='following the leader', msg='here'),
dict(one=1, pwd='$ecret k3y', url='https://username:********@foo.com/login/',
not_secret='following the leader', changed=False, msg='here',
invocation=dict(module_args=dict(password=OMIT, token=None, username='person'))),
),
(dict(username='person', password='$ecret k3y'),
(dict(username='person', password='$ecret k3y'),
dict(one=1, pwd='$ecret k3y', url='https://username:$ecret k3y@foo.com/login/',
not_secret='following the leader', msg='here'),
dict(one=1, pwd=OMIT, url='https://username:********@foo.com/login/',
not_secret='following the leader', changed=False, msg='here',
invocation=dict(module_args=dict(password=OMIT, token=None, username='person'))),
),
)
)
def test_exit_json_removes_values(self):
self.maxDiff = None

View file

@ -115,20 +115,20 @@ class TestAnsibleModuleLogSyslog(unittest.TestCase):
"""Test the AnsibleModule Log Method"""
py2_output_data = {
u'Text string': b'Text string',
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test'.encode('utf-8'),
b'Byte string': b'Byte string',
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test'.encode('utf-8'),
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace').encode('utf-8'),
}
u'Text string': b'Text string',
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test'.encode('utf-8'),
b'Byte string': b'Byte string',
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test'.encode('utf-8'),
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace').encode('utf-8'),
}
py3_output_data = {
u'Text string': u'Text string',
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
b'Byte string': u'Byte string',
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
}
u'Text string': u'Text string',
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
b'Byte string': u'Byte string',
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
}
def setUp(self):
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
@ -184,12 +184,12 @@ class TestAnsibleModuleLogJournal(unittest.TestCase):
"""Test the AnsibleModule Log Method"""
output_data = {
u'Text string': u'Text string',
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
b'Byte string': u'Byte string',
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
}
u'Text string': u'Text string',
u'Toshio くらとみ non-ascii test': u'Toshio くらとみ non-ascii test',
b'Byte string': u'Byte string',
u'Toshio くらとみ non-ascii test'.encode('utf-8'): u'Toshio くらとみ non-ascii test',
b'non-utf8 :\xff: test': b'non-utf8 :\xff: test'.decode('utf-8', 'replace')
}
# overriding run lets us use context managers for setup/teardown-esque behavior
def setUp(self):

View file

@ -34,21 +34,21 @@ from ansible.module_utils.basic import return_values, remove_values
class TestReturnValues(unittest.TestCase):
dataset = (
('string', frozenset(['string'])),
('', frozenset()),
(1, frozenset(['1'])),
(1.0, frozenset(['1.0'])),
(False, frozenset()),
(['1', '2', '3'], frozenset(['1', '2', '3'])),
(('1', '2', '3'), frozenset(['1', '2', '3'])),
({'one': 1, 'two': 'dos'}, frozenset(['1', 'dos'])),
({'one': 1, 'two': 'dos',
('string', frozenset(['string'])),
('', frozenset()),
(1, frozenset(['1'])),
(1.0, frozenset(['1.0'])),
(False, frozenset()),
(['1', '2', '3'], frozenset(['1', '2', '3'])),
(('1', '2', '3'), frozenset(['1', '2', '3'])),
({'one': 1, 'two': 'dos'}, frozenset(['1', 'dos'])),
({'one': 1, 'two': 'dos',
'three': ['amigos', 'musketeers', None,
{'ping': 'pong', 'base': ('balls', 'raquets')}]},
frozenset(['1', 'dos', 'amigos', 'musketeers', 'pong', 'balls', 'raquets'])),
(u'Toshio くらとみ', frozenset(['Toshio くらとみ'])),
('Toshio くらとみ', frozenset(['Toshio くらとみ'])),
)
(u'Toshio くらとみ', frozenset(['Toshio くらとみ'])),
('Toshio くらとみ', frozenset(['Toshio くらとみ'])),
)
def test_return_values(self):
for data, expected in self.dataset:
@ -61,46 +61,46 @@ class TestReturnValues(unittest.TestCase):
class TestRemoveValues(unittest.TestCase):
OMIT = 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
dataset_no_remove = (
('string', frozenset(['nope'])),
(1234, frozenset(['4321'])),
(False, frozenset(['4321'])),
(1.0, frozenset(['4321'])),
(['string', 'strang', 'strung'], frozenset(['nope'])),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['nope'])),
({'one': 1, 'two': 'dos',
('string', frozenset(['nope'])),
(1234, frozenset(['4321'])),
(False, frozenset(['4321'])),
(1.0, frozenset(['4321'])),
(['string', 'strang', 'strung'], frozenset(['nope'])),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['nope'])),
({'one': 1, 'two': 'dos',
'three': ['amigos', 'musketeers', None,
{'ping': 'pong', 'base': ['balls', 'raquets']}]},
frozenset(['nope'])),
('Toshio くら', frozenset(['とみ'])),
(u'Toshio くら', frozenset(['とみ'])),
)
('Toshio くら', frozenset(['とみ'])),
(u'Toshio くら', frozenset(['とみ'])),
)
dataset_remove = (
('string', frozenset(['string']), OMIT),
(1234, frozenset(['1234']), OMIT),
(1234, frozenset(['23']), OMIT),
(1.0, frozenset(['1.0']), OMIT),
(['string', 'strang', 'strung'], frozenset(['strang']), ['string', OMIT, 'strung']),
(['string', 'strang', 'strung'], frozenset(['strang', 'string', 'strung']), [OMIT, OMIT, OMIT]),
(('string', 'strang', 'strung'), frozenset(['string', 'strung']), [OMIT, 'strang', OMIT]),
((1234567890, 345678, 987654321), frozenset(['1234567890']), [OMIT, 345678, 987654321]),
((1234567890, 345678, 987654321), frozenset(['345678']), [OMIT, OMIT, 987654321]),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key']),
('string', frozenset(['string']), OMIT),
(1234, frozenset(['1234']), OMIT),
(1234, frozenset(['23']), OMIT),
(1.0, frozenset(['1.0']), OMIT),
(['string', 'strang', 'strung'], frozenset(['strang']), ['string', OMIT, 'strung']),
(['string', 'strang', 'strung'], frozenset(['strang', 'string', 'strung']), [OMIT, OMIT, OMIT]),
(('string', 'strang', 'strung'), frozenset(['string', 'strung']), [OMIT, 'strang', OMIT]),
((1234567890, 345678, 987654321), frozenset(['1234567890']), [OMIT, 345678, 987654321]),
((1234567890, 345678, 987654321), frozenset(['345678']), [OMIT, OMIT, 987654321]),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key']),
{'one': 1, 'two': 'dos', 'secret': OMIT}),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
{'one': OMIT, 'two': OMIT, 'secret': OMIT}),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
({'one': 1, 'two': 'dos', 'secret': 'key'}, frozenset(['key', 'dos', '1']),
{'one': OMIT, 'two': OMIT, 'secret': OMIT}),
({'one': 1, 'two': 'dos', 'three': ['amigos', 'musketeers', None,
({'one': 1, 'two': 'dos', 'three': ['amigos', 'musketeers', None,
{'ping': 'pong', 'base': ['balls', 'raquets']}]},
frozenset(['balls', 'base', 'pong', 'amigos']),
{'one': 1, 'two': 'dos', 'three': [OMIT, 'musketeers',
None, {'ping': OMIT, 'base': [OMIT, 'raquets']}]}),
('This sentence has an enigma wrapped in a mystery inside of a secret. - mr mystery',
('This sentence has an enigma wrapped in a mystery inside of a secret. - mr mystery',
frozenset(['enigma', 'mystery', 'secret']),
'This sentence has an ******** wrapped in a ******** inside of a ********. - mr ********'),
('Toshio くらとみ', frozenset(['くらとみ']), 'Toshio ********'),
(u'Toshio くらとみ', frozenset(['くらとみ']), u'Toshio ********'),
)
('Toshio くらとみ', frozenset(['くらとみ']), 'Toshio ********'),
(u'Toshio くらとみ', frozenset(['くらとみ']), u'Toshio ********'),
)
def test_no_removal(self):
for value, no_log_strings in self.dataset_no_remove:

View file

@ -30,27 +30,27 @@ from units.mock.generator import add_method
# Strings that should be converted into a typed value
VALID_STRINGS = (
[("'a'", 'a')],
[("'1'", '1')],
[("1", 1)],
[("True", True)],
[("False", False)],
[("{}", {})],
)
[("'a'", 'a')],
[("'1'", '1')],
[("1", 1)],
[("True", True)],
[("False", False)],
[("{}", {})],
)
# Passing things that aren't strings should just return the object
NONSTRINGS = (
[({'a':1}, {'a':1})],
)
[({'a':1}, {'a':1})],
)
# These strings are not basic types. For security, these should not be
# executed. We return the same string and get an exception for some
INVALID_STRINGS = (
[("a=1", "a=1", SyntaxError)],
[("a.foo()", "a.foo()", None)],
[("import foo", "import foo", None)],
[("__import__('foo')", "__import__('foo')", ValueError)],
)
[("a=1", "a=1", SyntaxError)],
[("a.foo()", "a.foo()", None)],
[("import foo", "import foo", None)],
[("__import__('foo')", "__import__('foo')", ValueError)],
)
def _check_simple_types(self, code, expected):

View file

@ -79,15 +79,15 @@ def _check_mode_unchanged_when_already_0660(self, mode):
SYNONYMS_0660 = (
[[0o660]],
[['0o660']],
[['660']],
)
[[0o660]],
[['0o660']],
[['660']],
)
@add_method(_check_no_mode_given_returns_previous_changes,
[dict(previous_changes=True)],
[dict(previous_changes=False)],
)
[dict(previous_changes=False)],
)
@add_method(_check_mode_changed_to_0660,
*SYNONYMS_0660
)
@ -131,8 +131,8 @@ def _check_knows_to_change_to_0660_in_check_mode(self, mode):
@add_method(_check_no_mode_given_returns_previous_changes,
[dict(previous_changes=True)],
[dict(previous_changes=False)],
)
[dict(previous_changes=False)],
)
@add_method(_check_knows_to_change_to_0660_in_check_mode,
*SYNONYMS_0660
)

View file

@ -46,12 +46,12 @@ class TestAnsibleModuleExitJson(unittest.TestCase):
junk = [u"single line of junk", u"line 1/2 of junk\nline 2/2 of junk"]
unparsable_cases = (
u'No json here',
u'"olá": "mundo"',
u'{"No json": "ending"',
u'{"wrong": "ending"]',
u'["wrong": "ending"}',
)
u'No json here',
u'"olá": "mundo"',
u'{"No json": "ending"',
u'{"wrong": "ending"]',
u'["wrong": "ending"}',
)
def test_just_json(self):
for i in self.all_inputs:

View file

@ -36,86 +36,86 @@ import ansible.module_utils.facts as facts
# to generate the testcase data, you can use the script gen_distribution_version_testcase.py in hacking/tests
TESTSETS = [
{
"platform.dist": [
"centos",
"7.2.1511",
"Core"
],
"input": {
"/etc/redhat-release": "CentOS Linux release 7.2.1511 (Core) \n",
"/etc/os-release": "NAME=\"CentOS Linux\"\nVERSION=\"7 (Core)\"\nID=\"centos\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"7\"\nPRETTY_NAME=\"CentOS Linux 7 (Core)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:centos:centos:7\"\nHOME_URL=\"https://www.centos.org/\"\nBUG_REPORT_URL=\"https://bugs.centos.org/\"\n\nCENTOS_MANTISBT_PROJECT=\"CentOS-7\"\nCENTOS_MANTISBT_PROJECT_VERSION=\"7\"\nREDHAT_SUPPORT_PRODUCT=\"centos\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"7\"\n\n",
"/etc/system-release": "CentOS Linux release 7.2.1511 (Core) \n"
},
"name": "CentOS 7.2.1511",
"result": {
"distribution_release": "Core",
"distribution": "CentOS",
"distribution_major_version": "7",
"os_family": "RedHat",
"distribution_version": "7.2.1511"
}
},
"platform.dist": [
"centos",
"7.2.1511",
"Core"
],
"input": {
"/etc/redhat-release": "CentOS Linux release 7.2.1511 (Core) \n",
"/etc/os-release": "NAME=\"CentOS Linux\"\nVERSION=\"7 (Core)\"\nID=\"centos\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"7\"\nPRETTY_NAME=\"CentOS Linux 7 (Core)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:centos:centos:7\"\nHOME_URL=\"https://www.centos.org/\"\nBUG_REPORT_URL=\"https://bugs.centos.org/\"\n\nCENTOS_MANTISBT_PROJECT=\"CentOS-7\"\nCENTOS_MANTISBT_PROJECT_VERSION=\"7\"\nREDHAT_SUPPORT_PRODUCT=\"centos\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"7\"\n\n",
"/etc/system-release": "CentOS Linux release 7.2.1511 (Core) \n"
},
"name": "CentOS 7.2.1511",
"result": {
"distribution_release": "Core",
"distribution": "CentOS",
"distribution_major_version": "7",
"os_family": "RedHat",
"distribution_version": "7.2.1511"
}
},
{
"name": "CentOS 6.7",
"platform.dist": [
"centos",
"6.7",
"Final"
],
"input": {
"/etc/redhat-release": "CentOS release 6.7 (Final)\n",
"/etc/lsb-release": "LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch\n",
"/etc/system-release": "CentOS release 6.7 (Final)\n"
},
"result": {
"distribution_release": "Final",
"distribution": "CentOS",
"distribution_major_version": "6",
"os_family": "RedHat",
"distribution_version": "6.7"
}
},
"name": "CentOS 6.7",
"platform.dist": [
"centos",
"6.7",
"Final"
],
"input": {
"/etc/redhat-release": "CentOS release 6.7 (Final)\n",
"/etc/lsb-release": "LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch\n",
"/etc/system-release": "CentOS release 6.7 (Final)\n"
},
"result": {
"distribution_release": "Final",
"distribution": "CentOS",
"distribution_major_version": "6",
"os_family": "RedHat",
"distribution_version": "6.7"
}
},
{
"name": "RedHat 7.2",
"platform.dist": [
"redhat",
"7.2",
"Maipo"
],
"input": {
"/etc/redhat-release": "Red Hat Enterprise Linux Server release 7.2 (Maipo)\n",
"/etc/os-release": "NAME=\"Red Hat Enterprise Linux Server\"\nVERSION=\"7.2 (Maipo)\"\nID=\"rhel\"\nID_LIKE=\"fedora\"\nVERSION_ID=\"7.2\"\nPRETTY_NAME=\"Red Hat Enterprise Linux Server 7.2 (Maipo)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:redhat:enterprise_linux:7.2:GA:server\"\nHOME_URL=\"https://www.redhat.com/\"\nBUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\n\nREDHAT_BUGZILLA_PRODUCT=\"Red Hat Enterprise Linux 7\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=7.2\nREDHAT_SUPPORT_PRODUCT=\"Red Hat Enterprise Linux\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"7.2\"\n",
"/etc/system-release": "Red Hat Enterprise Linux Server release 7.2 (Maipo)\n"
},
"result": {
"distribution_release": "Maipo",
"distribution": "RedHat",
"distribution_major_version": "7",
"os_family": "RedHat",
"distribution_version": "7.2"
}
},
{
"name": "RedHat 6.7",
"platform.dist": [
"redhat",
"6.7",
"Santiago"
],
"input": {
"/etc/redhat-release": "Red Hat Enterprise Linux Server release 6.7 (Santiago)\n",
"/etc/lsb-release": "LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch\n",
"/etc/system-release": "Red Hat Enterprise Linux Server release 6.7 (Santiago)\n"
},
"result": {
"distribution_release": "Santiago",
"distribution": "RedHat",
"distribution_major_version": "6",
"os_family": "RedHat",
"distribution_version": "6.7"
}
},
{
"name": "RedHat 7.2",
"platform.dist": [
"redhat",
"7.2",
"Maipo"
],
"input": {
"/etc/redhat-release": "Red Hat Enterprise Linux Server release 7.2 (Maipo)\n",
"/etc/os-release": "NAME=\"Red Hat Enterprise Linux Server\"\nVERSION=\"7.2 (Maipo)\"\nID=\"rhel\"\nID_LIKE=\"fedora\"\nVERSION_ID=\"7.2\"\nPRETTY_NAME=\"Red Hat Enterprise Linux Server 7.2 (Maipo)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:redhat:enterprise_linux:7.2:GA:server\"\nHOME_URL=\"https://www.redhat.com/\"\nBUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\n\nREDHAT_BUGZILLA_PRODUCT=\"Red Hat Enterprise Linux 7\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=7.2\nREDHAT_SUPPORT_PRODUCT=\"Red Hat Enterprise Linux\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"7.2\"\n",
"/etc/system-release": "Red Hat Enterprise Linux Server release 7.2 (Maipo)\n"
},
"result": {
"distribution_release": "Maipo",
"distribution": "RedHat",
"distribution_major_version": "7",
"os_family": "RedHat",
"distribution_version": "7.2"
}
},
{
"name": "RedHat 6.7",
"platform.dist": [
"redhat",
"6.7",
"Santiago"
],
"input": {
"/etc/redhat-release": "Red Hat Enterprise Linux Server release 6.7 (Santiago)\n",
"/etc/lsb-release": "LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch\n",
"/etc/system-release": "Red Hat Enterprise Linux Server release 6.7 (Santiago)\n"
},
"result": {
"distribution_release": "Santiago",
"distribution": "RedHat",
"distribution_major_version": "6",
"os_family": "RedHat",
"distribution_version": "6.7"
}
},
{
"name" : "openSUSE Leap 42.1",
"input": {
"/etc/os-release":
@ -604,84 +604,84 @@ DISTRIB_DESCRIPTION="CoreOS 976.0.0 (Coeur Rouge)"
"platform.system": "SunOS"
},
{
"name": "Solaris 11.3",
"platform.dist": [
"",
"",
""
],
"input": {
"/etc/release": " Oracle Solaris 11.3 X86\n Copyright (c) 1983, 2015, Oracle and/or its affiliates. All rights reserved.\n Assembled 06 October 2015\n"
},
"platform.system": "SunOS",
"result": {
"distribution_release": "Oracle Solaris 11.3 X86",
"distribution": "Solaris",
"os_family": "Solaris",
"distribution_version": "11.3"
}
},
{
"name": "Solaris 11.3",
"platform.dist": [
"",
"",
""
],
"input": {
"/etc/release": " Oracle Solaris 11.3 X86\n Copyright (c) 1983, 2015, Oracle and/or its affiliates. All rights reserved.\n Assembled 06 October 2015\n"
},
"platform.system": "SunOS",
"result": {
"distribution_release": "Oracle Solaris 11.3 X86",
"distribution": "Solaris",
"os_family": "Solaris",
"distribution_version": "11.3"
}
},
{
"name": "Solaris 10",
"platform.dist": [
"",
"",
""
],
"input": {
"/etc/release": " Oracle Solaris 10 1/13 s10x_u11wos_24a X86\n Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.\n Assembled 17 January 2013\n"
},
"platform.system": "SunOS",
"result": {
"distribution_release": "Oracle Solaris 10 1/13 s10x_u11wos_24a X86",
"distribution": "Solaris",
"os_family": "Solaris",
"distribution_version": "10"
}
},
{
"name": "Solaris 10",
"platform.dist": [
"",
"",
""
],
"input": {
"/etc/release": " Oracle Solaris 10 1/13 s10x_u11wos_24a X86\n Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.\n Assembled 17 January 2013\n"
},
"platform.system": "SunOS",
"result": {
"distribution_release": "Oracle Solaris 10 1/13 s10x_u11wos_24a X86",
"distribution": "Solaris",
"os_family": "Solaris",
"distribution_version": "10"
}
},
{
"name": "Fedora 22",
"platform.dist": [
"fedora",
"22",
"Twenty Two"
],
"input": {
"/etc/redhat-release": "Fedora release 22 (Twenty Two)\n",
"/etc/os-release": "NAME=Fedora\nVERSION=\"22 (Twenty Two)\"\nID=fedora\nVERSION_ID=22\nPRETTY_NAME=\"Fedora 22 (Twenty Two)\"\nANSI_COLOR=\"0;34\"\nCPE_NAME=\"cpe:/o:fedoraproject:fedora:22\"\nHOME_URL=\"https://fedoraproject.org/\"\nBUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\nREDHAT_BUGZILLA_PRODUCT=\"Fedora\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=22\nREDHAT_SUPPORT_PRODUCT=\"Fedora\"\nREDHAT_SUPPORT_PRODUCT_VERSION=22\nPRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy\n",
"/etc/system-release": "Fedora release 22 (Twenty Two)\n"
},
"result": {
"distribution_release": "Twenty Two",
"distribution": "Fedora",
"distribution_major_version": "22",
"os_family": "RedHat",
"distribution_version": "22"
}
},
{
"platform.dist": [
"fedora",
"25",
"Rawhide"
],
"input": {
"/etc/redhat-release": "Fedora release 25 (Rawhide)\n",
"/etc/os-release": "NAME=Fedora\nVERSION=\"25 (Workstation Edition)\"\nID=fedora\nVERSION_ID=25\nPRETTY_NAME=\"Fedora 25 (Workstation Edition)\"\nANSI_COLOR=\"0;34\"\nCPE_NAME=\"cpe:/o:fedoraproject:fedora:25\"\nHOME_URL=\"https://fedoraproject.org/\"\nBUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\nREDHAT_BUGZILLA_PRODUCT=\"Fedora\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=rawhide\nREDHAT_SUPPORT_PRODUCT=\"Fedora\"\nREDHAT_SUPPORT_PRODUCT_VERSION=rawhide\nPRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy\nVARIANT=\"Workstation Edition\"\nVARIANT_ID=workstation\n",
"/etc/system-release": "Fedora release 25 (Rawhide)\n"
},
"name": "Fedora 25",
"result": {
"distribution_release": "Rawhide",
"distribution": "Fedora",
"distribution_major_version": "25",
"os_family": "RedHat",
"distribution_version": "25"
}
},
{
"name": "Fedora 22",
"platform.dist": [
"fedora",
"22",
"Twenty Two"
],
"input": {
"/etc/redhat-release": "Fedora release 22 (Twenty Two)\n",
"/etc/os-release": "NAME=Fedora\nVERSION=\"22 (Twenty Two)\"\nID=fedora\nVERSION_ID=22\nPRETTY_NAME=\"Fedora 22 (Twenty Two)\"\nANSI_COLOR=\"0;34\"\nCPE_NAME=\"cpe:/o:fedoraproject:fedora:22\"\nHOME_URL=\"https://fedoraproject.org/\"\nBUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\nREDHAT_BUGZILLA_PRODUCT=\"Fedora\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=22\nREDHAT_SUPPORT_PRODUCT=\"Fedora\"\nREDHAT_SUPPORT_PRODUCT_VERSION=22\nPRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy\n",
"/etc/system-release": "Fedora release 22 (Twenty Two)\n"
},
"result": {
"distribution_release": "Twenty Two",
"distribution": "Fedora",
"distribution_major_version": "22",
"os_family": "RedHat",
"distribution_version": "22"
}
},
{
"platform.dist": [
"fedora",
"25",
"Rawhide"
],
"input": {
"/etc/redhat-release": "Fedora release 25 (Rawhide)\n",
"/etc/os-release": "NAME=Fedora\nVERSION=\"25 (Workstation Edition)\"\nID=fedora\nVERSION_ID=25\nPRETTY_NAME=\"Fedora 25 (Workstation Edition)\"\nANSI_COLOR=\"0;34\"\nCPE_NAME=\"cpe:/o:fedoraproject:fedora:25\"\nHOME_URL=\"https://fedoraproject.org/\"\nBUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\nREDHAT_BUGZILLA_PRODUCT=\"Fedora\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=rawhide\nREDHAT_SUPPORT_PRODUCT=\"Fedora\"\nREDHAT_SUPPORT_PRODUCT_VERSION=rawhide\nPRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy\nVARIANT=\"Workstation Edition\"\nVARIANT_ID=workstation\n",
"/etc/system-release": "Fedora release 25 (Rawhide)\n"
},
"name": "Fedora 25",
"result": {
"distribution_release": "Rawhide",
"distribution": "Fedora",
"distribution_major_version": "25",
"os_family": "RedHat",
"distribution_version": "25"
}
},
]

View file

@ -31,13 +31,13 @@ from ansible.module_utils._text import to_text, to_bytes, to_native
# Format: byte representation, text representation, encoding of byte representation
VALID_STRINGS = (
(b'abcde', u'abcde', 'ascii'),
(b'caf\xc3\xa9', u'caf\xe9', 'utf-8'),
(b'caf\xe9', u'caf\xe9', 'latin-1'),
# u'くらとみ'
(b'\xe3\x81\x8f\xe3\x82\x89\xe3\x81\xa8\xe3\x81\xbf', u'\u304f\u3089\u3068\u307f', 'utf-8'),
(b'\x82\xad\x82\xe7\x82\xc6\x82\xdd', u'\u304f\u3089\u3068\u307f', 'shift-jis'),
)
(b'abcde', u'abcde', 'ascii'),
(b'caf\xc3\xa9', u'caf\xe9', 'utf-8'),
(b'caf\xe9', u'caf\xe9', 'latin-1'),
# u'くらとみ'
(b'\xe3\x81\x8f\xe3\x82\x89\xe3\x81\xa8\xe3\x81\xbf', u'\u304f\u3089\u3068\u307f', 'utf-8'),
(b'\x82\xad\x82\xe7\x82\xc6\x82\xdd', u'\u304f\u3089\u3068\u307f', 'shift-jis'),
)
def _check_to_text(self, in_string, encoding, expected):
"""test happy path of decoding to text"""

View file

@ -57,13 +57,13 @@ def run(play):
results = None
try:
tqm = TaskQueueManager(
inventory=inventory,
variable_manager=variable_manager,
loader=loader,
options=options,
passwords=passwords,
stdout_callback='default',
)
inventory=inventory,
variable_manager=variable_manager,
loader=loader,
options=options,
passwords=passwords,
stdout_callback='default',
)
results = tqm.run(play)
finally:
if tqm is not None:

View file

@ -47,9 +47,9 @@ class TestModArgsDwim(unittest.TestCase):
self._debug(mod, args, to)
self.assertEqual(mod, 'command')
self.assertEqual(args, dict(
_raw_params = 'echo hi',
_uses_shell = True,
))
_raw_params = 'echo hi',
_uses_shell = True,
))
self.assertIsNone(to)
def test_basic_command(self):
@ -58,8 +58,8 @@ class TestModArgsDwim(unittest.TestCase):
self._debug(mod, args, to)
self.assertEqual(mod, 'command')
self.assertEqual(args, dict(
_raw_params = 'echo hi',
))
_raw_params = 'echo hi',
))
self.assertIsNone(to)
def test_shell_with_modifiers(self):
@ -68,11 +68,11 @@ class TestModArgsDwim(unittest.TestCase):
self._debug(mod, args, to)
self.assertEqual(mod, 'command')
self.assertEqual(args, dict(
creates = '/tmp/baz',
removes = '/tmp/bleep',
_raw_params = '/bin/foo',
_uses_shell = True,
))
creates = '/tmp/baz',
removes = '/tmp/bleep',
_raw_params = '/bin/foo',
_uses_shell = True,
))
self.assertIsNone(to)
def test_normal_usage(self):

View file

@ -39,10 +39,10 @@ class TestBlock(unittest.TestCase):
def test_load_block_simple(self):
ds = dict(
block = [],
rescue = [],
always = [],
#otherwise = [],
block = [],
rescue = [],
always = [],
#otherwise = [],
)
b = Block.load(ds)
self.assertEqual(b.block, [])
@ -53,10 +53,10 @@ class TestBlock(unittest.TestCase):
def test_load_block_with_tasks(self):
ds = dict(
block = [dict(action='block')],
rescue = [dict(action='rescue')],
always = [dict(action='always')],
#otherwise = [dict(action='otherwise')],
block = [dict(action='block')],
rescue = [dict(action='rescue')],
always = [dict(action='always')],
#otherwise = [dict(action='otherwise')],
)
b = Block.load(ds)
self.assertEqual(len(b.block), 1)
@ -77,9 +77,9 @@ class TestBlock(unittest.TestCase):
def test_deserialize(self):
ds = dict(
block = [dict(action='block')],
rescue = [dict(action='rescue')],
always = [dict(action='always')],
block = [dict(action='block')],
rescue = [dict(action='rescue')],
always = [dict(action='always')],
)
b = Block.load(ds)
data = dict(parent = ds, parent_type = 'Block')

View file

@ -186,7 +186,7 @@ class TestPlayContext(unittest.TestCase):
class TestTaskAndVariableOverrride(unittest.TestCase):
inventory_vars = (
('preferred_names',
('preferred_names',
dict(ansible_connection='local',
ansible_user='ansibull',
ansible_become_user='ansibull',
@ -198,11 +198,11 @@ class TestTaskAndVariableOverrride(unittest.TestCase):
become_method='su',
become_pass='ansibullwuzhere',)
),
('alternate_names',
('alternate_names',
dict(ansible_become_password='ansibullwuzhere',),
dict(become_pass='ansibullwuzhere',)
),
('deprecated_names',
('deprecated_names',
dict(ansible_ssh_user='ansibull',
ansible_sudo_user='ansibull',
ansible_sudo_pass='ansibullwuzhere',),
@ -211,7 +211,7 @@ class TestTaskAndVariableOverrride(unittest.TestCase):
become_user='ansibull',
become_pass='ansibullwuzhere',)
),
('deprecated_names2',
('deprecated_names2',
dict(ansible_ssh_user='ansibull',
ansible_su_user='ansibull',
ansible_su_pass='ansibullwuzhere',),
@ -220,17 +220,17 @@ class TestTaskAndVariableOverrride(unittest.TestCase):
become_user='ansibull',
become_pass='ansibullwuzhere',)
),
('deprecated_alt_names',
('deprecated_alt_names',
dict(ansible_sudo_password='ansibullwuzhere',),
dict(become_method='sudo',
become_pass='ansibullwuzhere',)
),
('deprecated_alt_names2',
('deprecated_alt_names2',
dict(ansible_su_password='ansibullwuzhere',),
dict(become_method='su',
become_pass='ansibullwuzhere',)
),
('deprecated_and_preferred_names',
('deprecated_and_preferred_names',
dict(ansible_user='ansibull',
ansible_ssh_user='badbull',
ansible_become_user='ansibull',
@ -245,7 +245,7 @@ class TestTaskAndVariableOverrride(unittest.TestCase):
become_method='su',
become_pass='ansibullwuzhere',)
),
)
)
def setUp(self):
parser = CLI.base_parser(

View file

@ -23,12 +23,12 @@ from ansible.playbook.task import Task
from ansible.compat.tests import unittest
basic_shell_task = dict(
name = 'Test Task',
shell = 'echo hi'
name = 'Test Task',
shell = 'echo hi'
)
kv_shell_task = dict(
action = 'shell echo hi'
action = 'shell echo hi'
)
class TestTask(unittest.TestCase):

View file

@ -28,26 +28,26 @@ class TestINILookup(unittest.TestCase):
# Currently there isn't a new-style
old_style_params_data = (
# Simple case
dict(term=u'keyA section=sectionA file=/path/to/file',
# Simple case
dict(term=u'keyA section=sectionA file=/path/to/file',
expected=[u'keyA', u'section=sectionA', u'file=/path/to/file'],
),
dict(term=u'keyB section=sectionB with space file=/path/with/embedded spaces and/file',
dict(term=u'keyB section=sectionB with space file=/path/with/embedded spaces and/file',
expected=[u'keyB', u'section=sectionB with space', u'file=/path/with/embedded spaces and/file'],
),
dict(term=u'keyC section=sectionC file=/path/with/equals/cn=com.ansible',
dict(term=u'keyC section=sectionC file=/path/with/equals/cn=com.ansible',
expected=[u'keyC', u'section=sectionC', u'file=/path/with/equals/cn=com.ansible'],
),
dict(term=u'keyD section=sectionD file=/path/with space and/equals/cn=com.ansible',
dict(term=u'keyD section=sectionD file=/path/with space and/equals/cn=com.ansible',
expected=[u'keyD', u'section=sectionD', u'file=/path/with space and/equals/cn=com.ansible'],
),
dict(term=u'keyE section=sectionE file=/path/with/unicode/くらとみ/file',
dict(term=u'keyE section=sectionE file=/path/with/unicode/くらとみ/file',
expected=[u'keyE', u'section=sectionE', u'file=/path/with/unicode/くらとみ/file'],
),
dict(term=u'keyF section=sectionF file=/path/with/utf 8 and spaces/くらとみ/file',
dict(term=u'keyF section=sectionF file=/path/with/utf 8 and spaces/くらとみ/file',
expected=[u'keyF', u'section=sectionF', u'file=/path/with/utf 8 and spaces/くらとみ/file'],
),
)
)
def setUp(self):

View file

@ -305,24 +305,24 @@ class TestParseContent(unittest.TestCase):
class TestFormatContent(unittest.TestCase):
def test_no_encrypt(self):
self.assertEqual(
password._format_content(password=u'hunter42',
password._format_content(password=u'hunter42',
salt=u'87654321',
encrypt=False),
u'hunter42 salt=87654321')
u'hunter42 salt=87654321')
def test_no_encrypt_no_salt(self):
self.assertEqual(
password._format_content(password=u'hunter42',
password._format_content(password=u'hunter42',
salt=None,
encrypt=False),
u'hunter42')
u'hunter42')
def test_encrypt(self):
self.assertEqual(
password._format_content(password=u'hunter42',
password._format_content(password=u'hunter42',
salt=u'87654321',
encrypt='pbkdf2_sha256'),
u'hunter42 salt=87654321')
u'hunter42 salt=87654321')
def test_encrypt_no_salt(self):
self.assertRaises(AssertionError, password._format_content,

View file

@ -34,7 +34,7 @@ class TestTemplar(unittest.TestCase):
def setUp(self):
fake_loader = DictDataLoader({
"/path/to/my_file.txt": "foo\n",
"/path/to/my_file.txt": "foo\n",
})
shared_loader = SharedPluginLoaderObj()
variables = dict(

View file

@ -30,45 +30,45 @@ from ansible.template import _escape_backslashes, _count_newlines_from_end
class TestBackslashEscape(unittest.TestCase):
test_data = (
# Test backslashes in a filter arg are double escaped
dict(
template=u"{{ 'test2 %s' | format('\\1') }}",
intermediate=u"{{ 'test2 %s' | format('\\\\1') }}",
expectation=u"test2 \\1",
args=dict()
),
# Test backslashes inside the jinja2 var itself are double
# escaped
dict(
template=u"Test 2\\3: {{ '\\1 %s' | format('\\2') }}",
intermediate=u"Test 2\\3: {{ '\\\\1 %s' | format('\\\\2') }}",
expectation=u"Test 2\\3: \\1 \\2",
args=dict()
),
# Test backslashes outside of the jinja2 var are not double
# escaped
dict(
template=u"Test 2\\3: {{ 'test2 %s' | format('\\1') }}; \\done",
intermediate=u"Test 2\\3: {{ 'test2 %s' | format('\\\\1') }}; \\done",
expectation=u"Test 2\\3: test2 \\1; \\done",
args=dict()
),
# Test backslashes in a variable sent to a filter are handled
dict(
template=u"{{ 'test2 %s' | format(var1) }}",
intermediate=u"{{ 'test2 %s' | format(var1) }}",
expectation=u"test2 \\1",
args=dict(var1=u'\\1')
),
# Test backslashes in a variable expanded by jinja2 are double
# escaped
dict(
template=u"Test 2\\3: {{ var1 | format('\\2') }}",
intermediate=u"Test 2\\3: {{ var1 | format('\\\\2') }}",
expectation=u"Test 2\\3: \\1 \\2",
args=dict(var1=u'\\1 %s')
),
)
# Test backslashes in a filter arg are double escaped
dict(
template=u"{{ 'test2 %s' | format('\\1') }}",
intermediate=u"{{ 'test2 %s' | format('\\\\1') }}",
expectation=u"test2 \\1",
args=dict()
),
# Test backslashes inside the jinja2 var itself are double
# escaped
dict(
template=u"Test 2\\3: {{ '\\1 %s' | format('\\2') }}",
intermediate=u"Test 2\\3: {{ '\\\\1 %s' | format('\\\\2') }}",
expectation=u"Test 2\\3: \\1 \\2",
args=dict()
),
# Test backslashes outside of the jinja2 var are not double
# escaped
dict(
template=u"Test 2\\3: {{ 'test2 %s' | format('\\1') }}; \\done",
intermediate=u"Test 2\\3: {{ 'test2 %s' | format('\\\\1') }}; \\done",
expectation=u"Test 2\\3: test2 \\1; \\done",
args=dict()
),
# Test backslashes in a variable sent to a filter are handled
dict(
template=u"{{ 'test2 %s' | format(var1) }}",
intermediate=u"{{ 'test2 %s' | format(var1) }}",
expectation=u"test2 \\1",
args=dict(var1=u'\\1')
),
# Test backslashes in a variable expanded by jinja2 are double
# escaped
dict(
template=u"Test 2\\3: {{ var1 | format('\\2') }}",
intermediate=u"Test 2\\3: {{ var1 | format('\\\\2') }}",
expectation=u"Test 2\\3: \\1 \\2",
args=dict(var1=u'\\1 %s')
),
)
def setUp(self):
self.env = jinja2.Environment()

View file

@ -30,39 +30,39 @@ from ansible.utils.vars import combine_vars, merge_hash
class TestVariableUtils(unittest.TestCase):
test_merge_data = (
dict(
a=dict(a=1),
b=dict(b=2),
result=dict(a=1, b=2)
dict(
a=dict(a=1),
b=dict(b=2),
result=dict(a=1, b=2)
),
dict(
a=dict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=dict(a=1, b=2, c=dict(foo='bar', baz='bam'))
dict(
a=dict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=dict(a=1, b=2, c=dict(foo='bar', baz='bam'))
),
dict(
a=defaultdict(a=1, c=defaultdict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=defaultdict(a=1, b=2, c=defaultdict(foo='bar', baz='bam'))
dict(
a=defaultdict(a=1, c=defaultdict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=defaultdict(a=1, b=2, c=defaultdict(foo='bar', baz='bam'))
),
)
)
test_replace_data = (
dict(
a=dict(a=1),
b=dict(b=2),
result=dict(a=1, b=2)
dict(
a=dict(a=1),
b=dict(b=2),
result=dict(a=1, b=2)
),
dict(
a=dict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=dict(a=1, b=2, c=dict(baz='bam'))
dict(
a=dict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=dict(a=1, b=2, c=dict(baz='bam'))
),
dict(
a=defaultdict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=defaultdict(baz='bam')),
result=defaultdict(a=1, b=2, c=defaultdict(baz='bam'))
dict(
a=defaultdict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=defaultdict(baz='bam')),
result=defaultdict(a=1, b=2, c=defaultdict(baz='bam'))
),
)
)
def setUp(self):
pass

View file

@ -237,8 +237,8 @@ class TestVariableManager(unittest.TestCase):
inv1.set_playbook_basedir('./')
play1 = Play.load(dict(
hosts=['all'],
roles=['defaults_only1', 'defaults_only2'],
hosts=['all'],
roles=['defaults_only1', 'defaults_only2'],
), loader=fake_loader, variable_manager=v)
# first we assert that the defaults as viewed as a whole are the merged results
@ -341,8 +341,8 @@ class TestVariableManager(unittest.TestCase):
})
play1 = Play.load(dict(
hosts=['all'],
roles=['role1', 'role2'],
hosts=['all'],
roles=['role1', 'role2'],
), loader=fake_loader, variable_manager=v)
# The task defined by common-role exists twice because role1