diff --git a/test/sanity/validate-modules/README.rst b/test/sanity/validate-modules/README.rst index 5da1d298320..1c39c5b9cc5 100644 --- a/test/sanity/validate-modules/README.rst +++ b/test/sanity/validate-modules/README.rst @@ -55,6 +55,7 @@ Errors #. New arguments have the correct ``version_added`` #. Modules should not import requests, instead use ``ansible.module_utils.urls`` #. Missing ``RETURN`` for new modules +#. Use of ``type()`` for type comparison instead of ``isinstance()`` Warnings ^^^^^^^^ diff --git a/test/sanity/validate-modules/test_validate_modules_regex.py b/test/sanity/validate-modules/test_validate_modules_regex.py new file mode 100644 index 00000000000..95b502e048b --- /dev/null +++ b/test/sanity/validate-modules/test_validate_modules_regex.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# This is a standalone test for the regex inside validate-modules +# It is not suitable to add to the make tests target because the +# file under test is outside the test's sys.path AND has a hyphen +# in the name making it unimportable. +# +# To execute this by hand: +# 1) cd +# 2) source hacking/env-setup +# 3) PYTHONPATH=./lib nosetests -d -w test -v --nocapture sanity/validate-modules + +import os +import re +from ansible.compat.tests import unittest + +#TYPE_REGEX = re.compile(r'.*\stype\(.*') +#TYPE_REGEX = re.compile(r'.*(if|or)\stype\(.*') +#TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)type\(.*') +#TYPE_REGEX = re.compile(r'.*(if|or)(\s+.*|\s+)type\(.*') +#TYPE_REGEX = re.compile(r'.*(if|\sor)(\s+.*|\s+)type\(.*') +#TYPE_REGEX = re.compile(r'.*(if|\sor)(\s+.*|\s+)(?