summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLovett, Trevor <trevor.lovett@att.com>2019-06-05 23:00:10 -0500
committerLovett, Trevor <trevor.lovett@att.com>2019-06-05 23:00:10 -0500
commit533930e4f25494316ea7bc06bcc84b452b2fa529 (patch)
tree03e1600013c62f4568d3908105ed2ee918fe5ac7
parent5f9c956c157b106014e7b5104a799c4fb818dba1 (diff)
[VVP] Removed yamllint library
Change-Id: If2c26b8650e8aba0a183d0cf47b1b3744dbfaf95 Issue-ID: VVP-201 Signed-off-by: Lovett, Trevor <trevor.lovett@att.com>
-rw-r--r--checks.py9
-rw-r--r--ice_validator/tests/conftest.py17
-rw-r--r--ice_validator/tests/test_initial_configuration.py40
-rw-r--r--requirements.txt3
4 files changed, 34 insertions, 35 deletions
diff --git a/checks.py b/checks.py
index 6f508eb..cde601a 100644
--- a/checks.py
+++ b/checks.py
@@ -167,9 +167,12 @@ def check_non_testable_requirements_are_not_mapped():
def check_flake8_passes():
- result = subprocess.run(["flake8", "."], encoding="utf-8",
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ result = subprocess.run(
+ ["flake8", "."],
+ encoding="utf-8",
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
msgs = result.stdout.split("\n") if result.returncode != 0 else []
return ["flake8 errors detected:"] + [f" {e}" for e in msgs] if msgs else []
diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py
index d07669c..69f6524 100644
--- a/ice_validator/tests/conftest.py
+++ b/ice_validator/tests/conftest.py
@@ -393,19 +393,26 @@ def pytest_collection_modifyitems(session, config, items):
):
item.add_marker(
pytest.mark.skip(
- reason=("Test categories do not match "
- "all the passed categories")
+ reason=(
+ "Test categories do not match "
+ "all the passed categories"
+ )
)
)
else:
item.add_marker(
pytest.mark.skip(
- reason=("Test belongs to a category but "
- "no categories were passed")
+ reason=(
+ "Test belongs to a category but "
+ "no categories were passed"
+ )
)
)
+
items.sort(
- key=lambda x: 0 if "base" in set(m.name for m in x.iter_markers()) else 1
+ key=lambda x: (0, x.name)
+ if "base" in set(m.name for m in x.iter_markers())
+ else (1, x.name)
)
diff --git a/ice_validator/tests/test_initial_configuration.py b/ice_validator/tests/test_initial_configuration.py
index 83f887c..f911ce9 100644
--- a/ice_validator/tests/test_initial_configuration.py
+++ b/ice_validator/tests/test_initial_configuration.py
@@ -38,41 +38,31 @@
from os import path
import pytest
+from yaml import YAMLError
from yaml.constructor import ConstructorError
from tests import cached_yaml as yaml
from tests.utils import yaml_custom_utils
-from .helpers import validates
-from yamllint.config import YamlLintConfig
-from yamllint import linter
-from .utils.nested_files import check_for_invalid_nesting
-from .utils.nested_iterables import find_all_get_resource_in_yml
-from .utils.nested_iterables import find_all_get_param_in_yml
+from tests.helpers import validates, load_yaml
+from tests.utils.nested_files import check_for_invalid_nesting
+from tests.utils.nested_iterables import find_all_get_resource_in_yml
+from tests.utils.nested_iterables import find_all_get_param_in_yml
@pytest.mark.base
@validates("R-95303")
def test_00_valid_yaml(filename):
- """
- Read in each .yaml or .env file. If it is successfully parsed as yaml, save
- contents, else add filename to list of bad yaml files. Log the result of
- parse attempt.
- """
- conf = YamlLintConfig("rules: {}")
-
- if path.splitext(filename)[-1] in [".yml", ".yaml", ".env"]:
- gen = linter.run(open(filename), conf)
- errors = list(gen)
-
- assert not errors, "Error parsing file {} with error {}".format(
- filename, errors
- )
- else:
- pytest.skip(
- "The file does not have any of the extensions .yml,\
- .yaml, or .env"
- )
+ if path.splitext(filename)[-1].lower() not in (".yml", ".yaml", ".env"):
+ pytest.skip("Not a YAML file")
+ try:
+ load_yaml(filename)
+ except YAMLError as e:
+ assert False, (
+ "Invalid YAML detected: {} "
+ "NOTE: Online YAML checkers such as yamllint.com "
+ "can helpful in diagnosing errors in YAML"
+ ).format(str(e).replace("\n", " "))
@pytest.mark.base
diff --git a/requirements.txt b/requirements.txt
index ae23630..df25186 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -46,8 +46,7 @@ docutils==0.14
requests==2.20.0
appdirs==1.4.3
jinja2==2.10
-yamllint==1.12.1
six==1.12.0
-pyinstaller
+pyinstaller
mock
openstack-heat