From 3842ae9dedb598d27a5d70439acfa4a9d1e66406 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 22 Feb 2016 10:01:41 -0600 Subject: [PATCH] Don't error on version_added for arg, if version_added should be the same as when the module was added. Fixes #18 --- ansible_testing/modules.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ansible_testing/modules.py b/ansible_testing/modules.py index 4ac54375a7..086c5f5bd0 100644 --- a/ansible_testing/modules.py +++ b/ansible_testing/modules.py @@ -411,8 +411,8 @@ class ModuleValidator(Validator): 'number: %r' % version_added) return - strict_ansible_version = StrictVersion(ansible_version) should_be = '.'.join(ansible_version.split('.')[:2]) + strict_ansible_version = StrictVersion(should_be) if (version_added < strict_ansible_version or strict_ansible_version < version_added): @@ -423,6 +423,8 @@ class ModuleValidator(Validator): if self._is_new_module(): return + mod_version_added = StrictVersion(str(doc.get('version_added', '0.0'))) + with CaptureStd(): try: existing = module_loader.find_plugin(self.name, mod_type='.py') @@ -441,8 +443,8 @@ class ModuleValidator(Validator): options = doc.get('options', {}) - strict_ansible_version = StrictVersion(ansible_version) should_be = '.'.join(ansible_version.split('.')[:2]) + strict_ansible_version = StrictVersion(should_be) for option, details in options.iteritems(): new = not bool(existing_options.get(option)) @@ -460,8 +462,9 @@ class ModuleValidator(Validator): (option, version_added)) continue - if (version_added < strict_ansible_version or - strict_ansible_version < version_added): + if (strict_ansible_version != mod_version_added and + (version_added < strict_ansible_version or + strict_ansible_version < version_added)): self.errors.append('version_added for new option (%s) should ' 'be %s. Currently %s' % (option, should_be, version_added))