aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.4k stars 577 forks source link

1.4.2: pytest fails in 6 units #3452

Open kloczek opened 2 days ago

kloczek commented 2 days ago

CloudFormation Lint Version

1.4.2

What operating system are you using?

Linux x86/64

Describe the bug

pytest fails in 6 units

Expected behavior

pytest shuld not fail

Reproduction template

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages + /usr/bin/pytest -ra -m 'not network' ============================= test session starts ============================== platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0 rootdir: /home/tkloczko/rpmbuild/BUILD/cfn-lint-1.4.2 configfile: pyproject.toml testpaths: test collected 1377 items test/integration/jsonschema/test_cfn_lint_rules.py . [ 0%] test/integration/jsonschema/test_resources_cfn_init.py . [ 0%] test/integration/jsonschema/test_validator_cfn.py ... [ 0%] test/integration/rules/test_rules.py . [ 0%] test/integration/test_data_file_format.py . [ 0%] test/integration/test_directives.py . [ 0%] test/integration/test_formatters.py F. [ 0%] test/integration/test_good_templates.py .. [ 0%] test/integration/test_mandatory_checks.py .. [ 1%] test/integration/test_patches.py . [ 1%] test/integration/test_quickstart_templates.py . [ 1%] test/integration/test_quickstart_templates_non_strict.py .. [ 1%] test/integration/test_schema_files.py ... [ 1%] test/integration/test_transform_ignore.py . [ 1%] test/unit/module/cfn_json/test_cfn_json.py .... [ 1%] test/unit/module/cfn_yaml/test_yaml.py ... [ 2%] test/unit/module/conditions/test_condition.py .... [ 2%] test/unit/module/conditions/test_conditions.py ........... [ 3%] test/unit/module/conditions/test_equals.py .... [ 3%] test/unit/module/config/test_cli_args.py ........... [ 4%] test/unit/module/config/test_config_file_args.py ......... [ 4%] test/unit/module/config/test_config_mixin.py ............. [ 5%] test/unit/module/config/test_logging.py ... [ 6%] test/unit/module/config/test_template_args.py ...... [ 6%] test/unit/module/context/test_conditions.py . [ 6%] test/unit/module/context/test_context.py . [ 6%] test/unit/module/context/test_create_context.py ..... [ 7%] test/unit/module/context/test_mappings.py .... [ 7%] test/unit/module/context/test_parameter.py .............. [ 8%] test/unit/module/context/test_path.py ... [ 8%] test/unit/module/context/test_resource.py ... [ 8%] test/unit/module/context/test_transforms.py ..... [ 9%] test/unit/module/custom_rules/test_custom_rules.py .............. [ 10%] test/unit/module/decode/test_convert_dict.py . [ 10%] test/unit/module/decode/test_decode.py .......... [ 10%] test/unit/module/formatters/test_formatters.py ..FF...F [ 11%] test/unit/module/helpers/test_create_rules.py . [ 11%] test/unit/module/helpers/test_downloads_metadata.py ... [ 11%] test/unit/module/helpers/test_format_json.py . [ 11%] test/unit/module/helpers/test_get_url_content.py ..... [ 12%] test/unit/module/helpers/test_get_url_retrieve.py .. [ 12%] test/unit/module/helpers/test_is_type_compatible.py ......... [ 13%] test/unit/module/helpers/test_load_plugins.py .. [ 13%] test/unit/module/helpers/test_regex_dict.py .... [ 13%] test/unit/module/jsonschema/test_exceptions.py ...... [ 13%] test/unit/module/jsonschema/test_filter.py .... [ 14%] test/unit/module/jsonschema/test_format.py . [ 14%] test/unit/module/jsonschema/test_keywords.py ... [ 14%] test/unit/module/jsonschema/test_keywords_cfn.py .... [ 14%] test/unit/module/jsonschema/test_resolvers_cfn.py ...................... [ 16%] ........................ [ 18%] test/unit/module/jsonschema/test_types.py .. [ 18%] test/unit/module/jsonschema/test_utils.py ... [ 18%] test/unit/module/jsonschema/test_validator.py .......................... [ 20%] ........................................................................ [ 25%] .................................. [ 28%] test/unit/module/jsonschema/test_validator_exceptions.py . [ 28%] test/unit/module/jsonschema/test_validator_resolver.py ... [ 28%] test/unit/module/maintenance/test_update_documentation.py F [ 28%] test/unit/module/maintenance/test_update_iam_policies.py . [ 28%] test/unit/module/override/test_complete.py .. [ 28%] test/unit/module/override/test_exclude.py .. [ 28%] test/unit/module/override/test_include.py . [ 28%] test/unit/module/override/test_required.py .. [ 29%] test/unit/module/rule/test_matching.py .. [ 29%] test/unit/module/rule/test_rule.py ..... [ 29%] test/unit/module/rule/test_rule_child.py ... [ 29%] test/unit/module/rule/test_rules.py ...... [ 30%] test/unit/module/runner/test_cli.py ..... [ 30%] test/unit/module/runner/test_exit_code.py . [ 30%] test/unit/module/runner/test_get_formatter.py ....... [ 31%] test/unit/module/runner/test_rule_configuration.py ... [ 31%] test/unit/module/runner/test_runner.py .. [ 31%] test/unit/module/schema/resolver/test_resolve_cfn_pointer.py . [ 31%] test/unit/module/schema/resolver/test_resolve_from_url.py . [ 31%] test/unit/module/schema/test_manager.py .......... [ 32%] test/unit/module/schema/test_schema.py .. [ 32%] test/unit/module/template/test_getatts.py ..... [ 32%] test/unit/module/template/test_template.py F............................ [ 35%] . [ 35%] test/unit/module/template/transforms/test_language_extensions.py ....... [ 35%] ............... [ 36%] test/unit/module/test_api.py ................ [ 37%] test/unit/module/test_duplicate.py .... [ 38%] test/unit/module/test_null_values.py .. [ 38%] test/unit/module/test_rules_collections.py ................ [ 39%] test/unit/module/test_string_template.py . [ 39%] test/unit/module/transform/test_transform.py ....... [ 40%] test/unit/rules/conditions/test_condition.py ... [ 40%] test/unit/rules/conditions/test_conditions.py . [ 40%] test/unit/rules/conditions/test_equals_is_useful.py ....... [ 40%] test/unit/rules/conditions/test_exists.py ... [ 41%] test/unit/rules/conditions/test_used.py .. [ 41%] test/unit/rules/custom/test_greater_operator.py .. [ 41%] test/unit/rules/custom/test_is_defined.py .. [ 41%] test/unit/rules/custom/test_is_not_defined.py .. [ 41%] test/unit/rules/custom/test_lesser_operator.py .. [ 41%] test/unit/rules/formats/test_format.py ....... [ 42%] test/unit/rules/formats/test_image_id.py ....... [ 42%] test/unit/rules/formats/test_security_group_id.py .... [ 43%] test/unit/rules/formats/test_security_group_name.py ... [ 43%] test/unit/rules/formats/test_vpc_id.py .... [ 43%] test/unit/rules/functions/test_base64.py ..... [ 43%] test/unit/rules/functions/test_basefn.py ... [ 44%] test/unit/rules/functions/test_cidr.py ...... [ 44%] test/unit/rules/functions/test_dynamic_reference.py ............. [ 45%] test/unit/rules/functions/test_dynamic_reference_secrets_manager_path.py . [ 45%] .. [ 45%] test/unit/rules/functions/test_dynamic_reference_secure_string.py .. [ 45%] test/unit/rules/functions/test_dynamic_reference_ssm_path.py ........... [ 46%] [ 46%] test/unit/rules/functions/test_find_in_map.py ........... [ 47%] test/unit/rules/functions/test_for_each.py .. [ 47%] test/unit/rules/functions/test_getatt.py .............. [ 48%] test/unit/rules/functions/test_getatt_format.py ..... [ 49%] test/unit/rules/functions/test_getaz.py .... [ 49%] test/unit/rules/functions/test_if.py ...... [ 49%] test/unit/rules/functions/test_importvalue.py ..... [ 50%] test/unit/rules/functions/test_join.py ......... [ 50%] test/unit/rules/functions/test_length.py ....... [ 51%] test/unit/rules/functions/test_ref.py ....... [ 51%] test/unit/rules/functions/test_relationship_conditions.py .. [ 51%] test/unit/rules/functions/test_select.py ........ [ 52%] test/unit/rules/functions/test_split.py ........ [ 53%] test/unit/rules/functions/test_sub.py .................... [ 54%] test/unit/rules/functions/test_sub_needed.py ... [ 54%] test/unit/rules/functions/test_sub_not_join.py ..... [ 55%] test/unit/rules/functions/test_sub_not_join_cdk.py . [ 55%] test/unit/rules/functions/test_sub_parameters_used.py .. [ 55%] test/unit/rules/functions/test_sub_unneeded.py ... [ 55%] test/unit/rules/functions/test_tojsonstring.py ....... [ 56%] test/unit/rules/jsonschema/test_base.py ... [ 56%] test/unit/rules/jsonschema/test_cfn_lint.py ... [ 56%] test/unit/rules/jsonschema/test_cfn_region_schema.py .. [ 56%] test/unit/rules/jsonschema/test_cfn_schema.py .. [ 56%] test/unit/rules/jsonschema/test_json_schema.py ... [ 57%] test/unit/rules/jsonschema/test_max_properties.py ... [ 57%] test/unit/rules/jsonschema/test_property_names.py ..... [ 57%] test/unit/rules/mappings/test_configuration.py ........ [ 58%] test/unit/rules/mappings/test_used.py .. [ 58%] test/unit/rules/metadata/test_cfn_lint.py .. [ 58%] test/unit/rules/metadata/test_config.py ... [ 58%] test/unit/rules/metadata/test_interface_configuration.py .. [ 58%] test/unit/rules/metadata/test_interface_parameter_exists.py .. [ 58%] test/unit/rules/outputs/test_condition.py ... [ 59%] test/unit/rules/outputs/test_configuration.py ....... [ 59%] test/unit/rules/outputs/test_export.py .... [ 59%] test/unit/rules/outputs/test_importvalue.py ... [ 60%] test/unit/rules/outputs/test_value.py ........ [ 60%] test/unit/rules/parameters/test_allowed_pattern.py . [ 60%] test/unit/rules/parameters/test_allowed_value.py . [ 60%] test/unit/rules/parameters/test_configuration.py ......... [ 61%] test/unit/rules/parameters/test_default.py ... [ 61%] test/unit/rules/parameters/test_dynamic_reference_secret.py .... [ 62%] test/unit/rules/parameters/test_no_echo.py .......... [ 62%] test/unit/rules/parameters/test_used.py ... [ 63%] test/unit/rules/resources/apigateway/test_restapi_openapi.py .... [ 63%] test/unit/rules/resources/backup/test_backup_plan_lifecycle_rule.py .... [ 63%] . [ 63%] test/unit/rules/resources/certificatemanager/test_domainvalidationoptions.py . [ 63%] ...... [ 64%] test/unit/rules/resources/cloudformation/test_nested_stack_parameters.py . [ 64%] . [ 64%] test/unit/rules/resources/cloudfront/test_aliases.py ................... [ 65%] ... [ 65%] test/unit/rules/resources/cloudwatch/test_alarm_aws_namespace_period.py . [ 66%] .... [ 66%] test/unit/rules/resources/codepipeline/test_stageactions.py ...... [ 66%] test/unit/rules/resources/codepipeline/test_stages.py ....... [ 67%] test/unit/rules/resources/dynamodb/test_attribute_mismatch.py .... [ 67%] test/unit/rules/resources/dynamodb/test_table_billingmode_exclusive.py . [ 67%] ... [ 67%] test/unit/rules/resources/dynamodb/test_table_billingmode_provisioned.py . [ 67%] ... [ 68%] test/unit/rules/resources/ec2/test_ebs.py ...... [ 68%] test/unit/rules/resources/ec2/test_rt_association.py .. [ 68%] test/unit/rules/resources/ec2/test_sg_all_to_and_from_ports.py ....... [ 69%] test/unit/rules/resources/ec2/test_sg_protocols_ports_exclusive.py ..... [ 69%] [ 69%] test/unit/rules/resources/ec2/test_sg_protocols_ports_inclusive.py .... [ 69%] test/unit/rules/resources/ecs/test_ecs_fargate.py ..... [ 70%] test/unit/rules/resources/ecs/test_task_definition_essentials.py ...... [ 70%] test/unit/rules/resources/ecs/test_task_definition_log_configuration.py . [ 70%] ... [ 70%] test/unit/rules/resources/elasticache/test_cache_cluster_failover.py .. [ 71%] test/unit/rules/resources/elb/test_certificate.py ... [ 71%] test/unit/rules/resources/elbv2/test_listener_certificate.py ... [ 71%] test/unit/rules/resources/elbv2/test_loadbalancer_application_subnets.py . [ 71%] .... [ 71%] test/unit/rules/resources/events/test_rule_schedule_expression.py ...... [ 72%] ............. [ 73%] test/unit/rules/resources/iam/test_iam_permissions.py ............. [ 74%] test/unit/rules/resources/iam/test_iam_policy_version.py ... [ 74%] test/unit/rules/resources/iam/test_identity_policy.py .... [ 74%] test/unit/rules/resources/iam/test_ref_with_path.py .. [ 74%] test/unit/rules/resources/iam/test_resource_ecr_policy.py . [ 74%] test/unit/rules/resources/iam/test_resource_policy.py ..... [ 75%] test/unit/rules/resources/iam/test_role_arn_pattern.py .... [ 75%] test/unit/rules/resources/lmbd/test_deprecated_runtime_create.py ...... [ 76%] test/unit/rules/resources/lmbd/test_deprecated_runtime_eol.py ...... [ 76%] test/unit/rules/resources/lmbd/test_deprecated_runtime_update.py ..... [ 76%] test/unit/rules/resources/lmbd/test_event_source_mapping_event_source_arn_sqs_exclusive.py . [ 76%] .. [ 77%] test/unit/rules/resources/lmbd/test_event_source_mapping_event_source_arn_stream_inclusive.py . [ 77%] .. [ 77%] test/unit/rules/resources/lmbd/test_events_log_group_name.py .. [ 77%] test/unit/rules/resources/lmbd/test_function_zipfile_runtime_enum.py ... [ 77%] .. [ 77%] test/unit/rules/resources/lmbd/test_function_zipfile_runtime_exists.py . [ 77%] .. [ 77%] test/unit/rules/resources/lmbd/test_snapstart.py .... [ 78%] test/unit/rules/resources/lmbd/test_snapstart_enabled.py .... [ 78%] test/unit/rules/resources/lmbd/test_snapstart_supported.py ........ [ 79%] test/unit/rules/resources/lmbd/test_zip_package_required_properties.py . [ 79%] . [ 79%] test/unit/rules/resources/properties/test_availability_zone.py ......... [ 79%] [ 79%] test/unit/rules/resources/properties/test_availability_zone_cdk.py . [ 80%] test/unit/rules/resources/properties/test_enum.py . [ 80%] test/unit/rules/resources/properties/test_image_id.py ... [ 80%] test/unit/rules/resources/properties/test_number_range.py .... [ 80%] test/unit/rules/resources/properties/test_password.py .. [ 80%] test/unit/rules/resources/properties/test_pattern.py .. [ 80%] test/unit/rules/resources/properties/test_properties.py ... [ 81%] test/unit/rules/resources/properties/test_properties_templated.py .... [ 81%] test/unit/rules/resources/properties/test_read_only.py ...... [ 81%] test/unit/rules/resources/properties/test_string_length.py ............. [ 82%] ......................... [ 84%] test/unit/rules/resources/properties/test_tagging.py ....... [ 85%] test/unit/rules/resources/properties/test_unique_items.py .... [ 85%] test/unit/rules/resources/properties/test_value_primitive_type.py .. [ 85%] test/unit/rules/resources/rds/test_db_cluster_aurora.py .... [ 85%] test/unit/rules/resources/rds/test_db_cluster_engine_version.py ...... [ 86%] test/unit/rules/resources/rds/test_db_cluster_instance_class_enum.py ... [ 86%] .. [ 86%] test/unit/rules/resources/rds/test_db_cluster_monitoring.py ..... [ 87%] test/unit/rules/resources/rds/test_db_cluster_multiaz.py ...... [ 87%] test/unit/rules/resources/rds/test_db_cluster_serverless_exclusive.py .. [ 87%] .... [ 87%] test/unit/rules/resources/rds/test_db_cluster_snapshotidentifier.py ... [ 88%] test/unit/rules/resources/rds/test_db_cluster_sourcedbclusteridentifier.py . [ 88%] .. [ 88%] test/unit/rules/resources/rds/test_db_instance_aurora_exclusive.py ..... [ 88%] .. [ 88%] test/unit/rules/resources/rds/test_db_instance_db_instance_class_enum.py . [ 88%] ......... [ 89%] test/unit/rules/resources/rds/test_db_instance_engine_version.py ....... [ 90%] . [ 90%] test/unit/rules/resources/route53/test_health_check_health_check_config_type_inclusive.py . [ 90%] ... [ 90%] test/unit/rules/resources/route53/test_recordset_alias.py ... [ 90%] test/unit/rules/resources/route53/test_recordset_name.py ....... [ 91%] test/unit/rules/resources/route53/test_recordsets.py .............. [ 92%] test/unit/rules/resources/s3/test_access_control_obsolete.py ... [ 92%] test/unit/rules/resources/s3/test_access_control_ownership.py ....... [ 92%] test/unit/rules/resources/stepfunctions/test_state_machine.py .. [ 93%] test/unit/rules/resources/test_both_update_replace_delete_policy.py .... [ 93%] [ 93%] test/unit/rules/resources/test_cfn_init.py .. [ 93%] test/unit/rules/resources/test_circular_dependency.py .... [ 93%] test/unit/rules/resources/test_condition.py ... [ 93%] test/unit/rules/resources/test_configurations.py . [ 94%] test/unit/rules/resources/test_deletionpolicy.py .... [ 94%] test/unit/rules/resources/test_deletionpolicy_stateful_resources.py .... [ 94%] [ 94%] test/unit/rules/resources/test_dependson.py ........ [ 95%] test/unit/rules/resources/test_dependson_obsolete.py .... [ 95%] test/unit/rules/resources/test_hardcodedarnproperties.py .... [ 95%] test/unit/rules/resources/test_modules.py ..... [ 96%] test/unit/rules/resources/test_previous_generation_instance_type.py .. [ 96%] test/unit/rules/resources/test_primary_identifiers.py .. [ 96%] test/unit/rules/resources/test_retentionperiod.py .... [ 96%] test/unit/rules/resources/test_retentionperiod_rds.py ... [ 96%] test/unit/rules/resources/test_serverless_transform.py .... [ 97%] test/unit/rules/resources/test_type.py ... [ 97%] test/unit/rules/resources/test_unique_names.py .. [ 97%] test/unit/rules/resources/test_updatereplacepolicy.py .... [ 97%] test/unit/rules/resources/updatepolicy/test_configuration.py ....... [ 98%] test/unit/rules/templates/test_base_template.py ...... [ 98%] test/unit/rules/templates/test_description.py .. [ 98%] test/unit/rules/templates/test_limitsize_description.py ...... [ 99%] test/unit/rules/templates/test_limitsize_description_approaching.py .. [ 99%] test/unit/rules/templates/test_limitsize_template.py .. [ 99%] test/unit/rules/templates/test_yaml_template.py . [ 99%] test/unit/rules/test_base_json_schema.py ... [100%] =================================== FAILURES =================================== __________________________ TestFormatters.test_junit ___________________________ self = def test_junit(self): """Test JUnit formatting""" > result = subprocess.check_output( [ "cfn-lint", "--format", "junit", "--", "test/fixtures/templates/good/core/config_only_*.yaml", ] ) test/integration/test_formatters.py:15: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib64/python3.10/subprocess.py:421: in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input = None, capture_output = False, timeout = None, check = True popenargs = (['cfn-lint', '--format', 'junit', '--', 'test/fixtures/templates/good/core/config_only_*.yaml'],) kwargs = {'stdout': -1} process = stdout = b'', stderr = None, retcode = 1 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs): """Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them, or pass capture_output=True to capture both. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout is given, and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. """ if input is not None: if kwargs.get('stdin') is not None: raise ValueError('stdin and input arguments may not both be used.') kwargs['stdin'] = PIPE if capture_output: if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None: raise ValueError('stdout and stderr arguments may not be used ' 'with capture_output.') kwargs['stdout'] = PIPE kwargs['stderr'] = PIPE with Popen(*popenargs, **kwargs) as process: try: stdout, stderr = process.communicate(input, timeout=timeout) except TimeoutExpired as exc: process.kill() if _mswindows: # Windows accumulates the output in a single blocking # read() call run on child threads, with the timeout # being done in a join() on those threads. communicate() # _after_ kill() is required to collect that and add it # to the exception. exc.stdout, exc.stderr = process.communicate() else: # POSIX _communicate already populated the output so # far into the TimeoutExpired exception. process.wait() raise except: # Including KeyboardInterrupt, communicate handled that. process.kill() # We don't call process.wait() as .__exit__ does that for us. raise retcode = process.poll() if check and retcode: > raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr) E subprocess.CalledProcessError: Command '['cfn-lint', '--format', 'junit', '--', 'test/fixtures/templates/good/core/config_only_*.yaml']' returned non-zero exit status 1. /usr/lib64/python3.10/subprocess.py:526: CalledProcessError ----------------------------- Captured stderr call ----------------------------- Traceback (most recent call last): File "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/junit.py", line 23, in print_matches from junit_xml import TestCase, TestSuite, to_xml_report_string ModuleNotFoundError: No module named 'junit_xml' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/bin/cfn-lint", line 8, in sys.exit(main()) File "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/runner.py", line 429, in main runner.cli() File "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/runner.py", line 423, in cli self._cli_output(list(self.run())) File "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/runner.py", line 315, in _cli_output output = formatter.print_matches(matches, self.rules, config=self.config) File "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/junit.py", line 25, in print_matches raise ImportError("Missing optional dependencies junit") from e ImportError: Missing optional dependencies junit _____________________ TestFormatters.test_junit_formatter ______________________ self = matches = [[I3011: Check stateful resources have a set UpdateReplacePolicy/DeletionPolicy] (The default action when replacing/re...heck resource properties values] ('5' is not of type 'integer') matched test/fixtures/templates/bad/formatters.yaml:18] rules = E0000: Parsing error found when parsing the template Checks for JSON/YAML formatting errors in your template E0001: Er...se Validate Fn::Equals to see if its comparing two strings or two equal items. While this works it may not be intended. config = { "append_rules": [ "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-...rride_spec": null, "regions": [ "us-east-1" ], "templates": [ "test/fixtures/templates/bad/formatters.yaml" ] } def print_matches(self, matches, rules, config): """Output all the matches""" try: > from junit_xml import TestCase, TestSuite, to_xml_report_string E ModuleNotFoundError: No module named 'junit_xml' ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/junit.py:23: ModuleNotFoundError The above exception was the direct cause of the following exception: self = def test_junit_formatter(self): """Test JUnit Formatter""" formatter = JUnitFormatter() self.rules._used_rules = { "I3011": self.rules["I3011"], "E3012": self.rules["E3012"], "W1020": self.rules["W1020"], } > s = formatter.print_matches(self.results, self.rules, self.config) test/unit/module/formatters/test_formatters.py:249: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = matches = [[I3011: Check stateful resources have a set UpdateReplacePolicy/DeletionPolicy] (The default action when replacing/re...heck resource properties values] ('5' is not of type 'integer') matched test/fixtures/templates/bad/formatters.yaml:18] rules = E0000: Parsing error found when parsing the template Checks for JSON/YAML formatting errors in your template E0001: Er...se Validate Fn::Equals to see if its comparing two strings or two equal items. While this works it may not be intended. config = { "append_rules": [ "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-...rride_spec": null, "regions": [ "us-east-1" ], "templates": [ "test/fixtures/templates/bad/formatters.yaml" ] } def print_matches(self, matches, rules, config): """Output all the matches""" try: from junit_xml import TestCase, TestSuite, to_xml_report_string except ImportError as e: > raise ImportError("Missing optional dependencies junit") from e E ImportError: Missing optional dependencies junit ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/junit.py:25: ImportError ____________________ TestFormatters.test_junit_returns_none ____________________ self = matches = [], rules = [] config = { "append_rules": [ "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-...rride_spec": null, "regions": [ "us-east-1" ], "templates": [ "test/fixtures/templates/bad/formatters.yaml" ] } def print_matches(self, matches, rules, config): """Output all the matches""" try: > from junit_xml import TestCase, TestSuite, to_xml_report_string E ModuleNotFoundError: No module named 'junit_xml' ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/junit.py:23: ModuleNotFoundError The above exception was the direct cause of the following exception: self = def test_junit_returns_none(self): """Test JUnut Formatter returns None if no rules are passed in""" formatter = JUnitFormatter() # The actual test > self.assertIsNone(formatter.print_matches([], [], self.config)) test/unit/module/formatters/test_formatters.py:238: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = matches = [], rules = [] config = { "append_rules": [ "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-...rride_spec": null, "regions": [ "us-east-1" ], "templates": [ "test/fixtures/templates/bad/formatters.yaml" ] } def print_matches(self, matches, rules, config): """Output all the matches""" try: from junit_xml import TestCase, TestSuite, to_xml_report_string except ImportError as e: > raise ImportError("Missing optional dependencies junit") from e E ImportError: Missing optional dependencies junit ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/junit.py:25: ImportError _____________________ TestFormatters.test_sarif_formatter ______________________ self = matches = [[I3011: Check stateful resources have a set UpdateReplacePolicy/DeletionPolicy] (The default action when replacing/re...heck resource properties values] ('5' is not of type 'integer') matched test/fixtures/templates/bad/formatters.yaml:18] rules = E0000: Parsing error found when parsing the template Checks for JSON/YAML formatting errors in your template E0001: Er...se Validate Fn::Equals to see if its comparing two strings or two equal items. While this works it may not be intended. config = { "append_rules": [ "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-...rride_spec": null, "regions": [ "us-east-1" ], "templates": [ "test/fixtures/templates/bad/formatters.yaml" ] } def print_matches(self, matches, rules, config): """Output all the matches""" try: > import sarif_om as sarif E ModuleNotFoundError: No module named 'sarif_om' ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/sarif.py:45: ModuleNotFoundError The above exception was the direct cause of the following exception: self = def test_sarif_formatter(self): """Test the SARIF formatter""" formatter = SARIFFormatter() # Get the SARIF JSON output sarif = json.loads( > formatter.print_matches(self.results, self.rules, self.config) ) test/unit/module/formatters/test_formatters.py:295: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = matches = [[I3011: Check stateful resources have a set UpdateReplacePolicy/DeletionPolicy] (The default action when replacing/re...heck resource properties values] ('5' is not of type 'integer') matched test/fixtures/templates/bad/formatters.yaml:18] rules = E0000: Parsing error found when parsing the template Checks for JSON/YAML formatting errors in your template E0001: Er...se Validate Fn::Equals to see if its comparing two strings or two equal items. While this works it may not be intended. config = { "append_rules": [ "/home/tkloczko/rpmbuild/BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-...rride_spec": null, "regions": [ "us-east-1" ], "templates": [ "test/fixtures/templates/bad/formatters.yaml" ] } def print_matches(self, matches, rules, config): """Output all the matches""" try: import sarif_om as sarif from jschema_to_python.to_json import to_json except ImportError as e: > raise ImportError("Missing optional dependencies sarif") from e E ImportError: Missing optional dependencies sarif ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/formatters/sarif.py:48: ImportError ___________________ TestUpdateDocumentation.test_update_docs ___________________ self = def test_update_docs(self): collection = Rules.create_from_directory(_DEFAULT_RULESDIR + "/errors") builtin_module_name = "builtins" mo = mock_open(read_data=self.TEST_TEXT) mo.return_value.__iter__ = lambda self: self mo.return_value.__iter__ = lambda self: iter(self.readline, "") with patch("{}.open".format(builtin_module_name), mo) as mock_builtin_open: > cfnlint.maintenance.update_documentation(collection) test/unit/module/maintenance/test_update_documentation.py:34: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../BUILDROOT/python-cfn-lint-1.4.2-2.fc37.x86_64/usr/lib/python3.10/site-packages/cfnlint/maintenance.py:82: in update_documentation + subprocess.check_output( /usr/lib64/python3.10/subprocess.py:421: in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, /usr/lib64/python3.10/subprocess.py:503: in run with Popen(*popenargs, **kwargs) as process: /usr/lib64/python3.10/subprocess.py:971: in __init__ self._execute_child(args, executable, preexec_fn, close_fds, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = args = ['git', 'grep', '-l', 'id = "E0000"', 'src/cfnlint/rules/'] executable = b'git', preexec_fn = None, close_fds = True, pass_fds = () cwd = None, env = None, startupinfo = None, creationflags = 0, shell = False p2cread = -1, p2cwrite = -1, c2pread = 11, c2pwrite = 12, errread = -1 errwrite = -1, restore_signals = True, gid = None, gids = None, uid = None umask = -1, start_new_session = False def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session): """Execute program (POSIX version)""" if isinstance(args, (str, bytes)): args = [args] elif isinstance(args, os.PathLike): if shell: raise TypeError('path-like args is not allowed when ' 'shell is true') args = [args] else: args = list(args) if shell: # On Android the default shell is at '/system/bin/sh'. unix_shell = ('/system/bin/sh' if hasattr(sys, 'getandroidapilevel') else '/bin/sh') args = [unix_shell, "-c"] + args if executable: args[0] = executable if executable is None: executable = args[0] sys.audit("subprocess.Popen", executable, args, cwd, env) if (_USE_POSIX_SPAWN and os.path.dirname(executable) and preexec_fn is None and not close_fds and not pass_fds and cwd is None and (p2cread == -1 or p2cread > 2) and (c2pwrite == -1 or c2pwrite > 2) and (errwrite == -1 or errwrite > 2) and not start_new_session and gid is None and gids is None and uid is None and umask < 0): self._posix_spawn(args, executable, env, restore_signals, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) return orig_executable = executable # For transferring possible exec failure from child to parent. # Data format: "exception name:hex errno:description" # Pickle is not used; it is complex and involves memory allocation. errpipe_read, errpipe_write = os.pipe() # errpipe_write must not be in the standard io 0, 1, or 2 fd range. low_fds_to_close = [] while errpipe_write < 3: low_fds_to_close.append(errpipe_write) errpipe_write = os.dup(errpipe_write) for low_fd in low_fds_to_close: os.close(low_fd) try: try: # We must avoid complex work that could involve # malloc or free in the child process to avoid # potential deadlocks, thus we do all this here. # and pass it to fork_exec() if env is not None: env_list = [] for k, v in env.items(): k = os.fsencode(k) if b'=' in k: raise ValueError("illegal environment variable name") env_list.append(k + b'=' + os.fsencode(v)) else: env_list = None # Use execv instead of execve. executable = os.fsencode(executable) if os.path.dirname(executable): executable_list = (executable,) else: # This matches the behavior of os._execvpe(). executable_list = tuple( os.path.join(os.fsencode(dir), executable) for dir in os.get_exec_path(env)) fds_to_keep = set(pass_fds) fds_to_keep.add(errpipe_write) self.pid = _posixsubprocess.fork_exec( args, executable_list, close_fds, tuple(sorted(map(int, fds_to_keep))), cwd, env_list, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, errpipe_read, errpipe_write, restore_signals, start_new_session, gid, gids, uid, umask, preexec_fn) self._child_created = True finally: # be sure the FD is closed no matter what os.close(errpipe_write) self._close_pipe_fds(p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) # Wait for exec to fail or succeed; possibly raising an # exception (limited in size) errpipe_data = bytearray() while True: part = os.read(errpipe_read, 50000) errpipe_data += part if not part or len(errpipe_data) > 50000: break finally: # be sure the FD is closed no matter what os.close(errpipe_read) if errpipe_data: try: pid, sts = os.waitpid(self.pid, 0) if pid == self.pid: self._handle_exitstatus(sts) else: self.returncode = sys.maxsize except ChildProcessError: pass try: exception_name, hex_errno, err_msg = ( errpipe_data.split(b':', 2)) # The encoding here should match the encoding # written in by the subprocess implementations # like _posixsubprocess err_msg = err_msg.decode() except ValueError: exception_name = b'SubprocessError' hex_errno = b'0' err_msg = 'Bad exception data from child: {!r}'.format( bytes(errpipe_data)) child_exception_type = getattr( builtins, exception_name.decode('ascii'), SubprocessError) if issubclass(child_exception_type, OSError) and hex_errno: errno_num = int(hex_errno, 16) child_exec_never_called = (err_msg == "noexec") if child_exec_never_called: err_msg = "" # The error must be from chdir(cwd). err_filename = cwd else: err_filename = orig_executable if errno_num != 0: err_msg = os.strerror(errno_num) > raise child_exception_type(errno_num, err_msg, err_filename) E FileNotFoundError: [Errno 2] No such file or directory: 'git' /usr/lib64/python3.10/subprocess.py:1863: FileNotFoundError ________________________ TestTemplate.test_build_graph _________________________ self = def test_build_graph(self): self.template.build_graph() dot = "test/fixtures/templates/good/generic.yaml.dot" # ruff: noqa: E501 expected_content = """digraph "template" { MyModule [color=black, label="MyModule\\n", shape=ellipse, type=Resource]; RootRole [color=black, label="RootRole\\n", shape=ellipse, type=Resource]; RolePolicies [color=black, label="RolePolicies\\n", shape=ellipse, type=Resource]; RootInstanceProfile [color=black, label="RootInstanceProfile\\n", shape=ellipse, type=Resource]; MyEC2Instance [color=black, label="MyEC2Instance\\n", shape=ellipse, type=Resource]; mySnsTopic [color=black, label="mySnsTopic\\n", shape=ellipse, type=Resource]; MyEC2Instance1 [color=black, label="MyEC2Instance1\\n", shape=ellipse, type=Resource]; ElasticIP [color=black, label="ElasticIP\\n", shape=ellipse, type=Resource]; ElasticLoadBalancer [color=black, label="ElasticLoadBalancer\\n", shape=ellipse, type=Resource]; IamPipeline [color=black, label="IamPipeline\\n", shape=ellipse, type=Resource]; CustomResource [color=black, label="CustomResource\\n", shape=ellipse, type=Resource]; WaitCondition [color=black, label="WaitCondition\\n", shape=ellipse, type=Resource]; LambdaFunction [color=black, label="LambdaFunction\\n", shape=ellipse, type=Resource]; RolePolicies -> RootRole [color=black, key=0, label=Ref, source_paths="['Properties', 'Roles', 0]"]; RootInstanceProfile -> RootRole [color=black, key=0, label=Ref, source_paths="['Properties', 'Roles', 0]"]; MyEC2Instance -> RootInstanceProfile [color=black, key=0, label=Ref, source_paths="['Properties', 'IamInstanceProfile']"]; ElasticLoadBalancer -> MyEC2Instance [color=black, key=0, label=Ref, source_paths="['Properties', 'Instances', 0]"]; } """.split( "\n" ) assert os.path.exists(dot) with open(dot, "r") as file: file_contents = file.read().split("\n") # doing set equality instead of string equality because python 2.7 and 3.8 produce the same graph but with different edge order > assert len(file_contents) == len( expected_content ), f"Length {len(file_contents)} != {len(expected_content)}" E AssertionError: Length 1 != 20 E assert 1 == 20 E + where 1 = len(['']) E + and 20 = len(['digraph "template" {', 'MyModule [color=black, label="MyModule\\n", shape=ellipse,...ce];', 'MyEC2Instance [color=black, label="MyEC2Instance\\n", shape=ellipse, type=Resource];', ...]) test/unit/module/template/test_template.py:70: AssertionError ----------------------------- Captured stderr call ----------------------------- 2024-06-30 11:38:50,782 - cfnlint.template.template - ERROR - Could not write the graph in DOT format. Please install either `pygraphviz` or `pydot` modules. ------------------------------ Captured log call ------------------------------- ERROR cfnlint.template.template:template.py:128 Could not write the graph in DOT format. Please install either `pygraphviz` or `pydot` modules. =========================== short test summary info ============================ FAILED test/integration/test_formatters.py::TestFormatters::test_junit - subp... FAILED test/unit/module/formatters/test_formatters.py::TestFormatters::test_junit_formatter FAILED test/unit/module/formatters/test_formatters.py::TestFormatters::test_junit_returns_none FAILED test/unit/module/formatters/test_formatters.py::TestFormatters::test_sarif_formatter FAILED test/unit/module/maintenance/test_update_documentation.py::TestUpdateDocumentation::test_update_docs FAILED test/unit/module/template/test_template.py::TestTemplate::test_build_graph ================== 6 failed, 1371 passed in 295.92s (0:04:55) ================== ```
List of installed modules in build env: ```console Package Version ------------------------- ----------- annotated-types 0.7.0 attrs 23.2.0 aws-sam-translator 1.89.0 boto3 1.34.136 botocore 1.34.136 build 1.2.1 defusedxml 0.7.1 distro 1.9.0 exceptiongroup 1.1.3 importlib_metadata 8.0.0 iniconfig 2.0.0 installer 0.7.0 jmespath 1.0.1 jsonpatch 1.33 jsonpointer 2.4 jsonschema 4.20.0 jsonschema-specifications 2023.12.1 mpmath 1.3.0 networkx 3.3 packaging 24.0 pluggy 1.5.0 pydantic 2.7.4 pydantic_core 2.18.4 pyproject_hooks 1.0.0 pytest 8.2.2 python-dateutil 2.9.0.post0 PyYAML 6.0.1 referencing 0.32.0 regex 2024.5.15 rpds-py 0.18.1 s3transfer 0.10.2 setuptools 69.4.0 sympy 1.12.1 tokenize_rt 5.2.0 tomli 2.0.1 typing_extensions 4.12.2 urllib3 2.2.2 wheel 0.43.0 zipp 3.19.2 ```

Please let me know if you need more details or want me to perform some diagnostics.

kddejong commented 5 hours ago

We are using extras for optional dependencies. I've added a full so you can do install pip install cfn-lint[full] This will include all the optional dependencies. Its what we are using to install the packages for our testing.

kloczek commented 3 hours ago

OK however .. what is the sense adding some dependencies to extras if those dependencies are essential to pass pytest without additional params? 🤔