Closes #27: Check that definition files end with a blank line

This commit is contained in:
Jeremy Stretch 2019-12-30 10:11:25 -05:00
parent bbe3ab6542
commit 1c98c069b8
2 changed files with 9 additions and 2 deletions

View File

@ -32,6 +32,7 @@ Additionally, be sure to adhere to the following style guidance:
* Use two spaces for indenting.
* Specify a device type's attributes before listing its components.
* Avoid encapsulating YAML values in quotes unless necessary to avoid a syntax error.
* End each definition file with a blank line.
## The Contribution Workflow

View File

@ -32,14 +32,20 @@ def test_environment():
@pytest.mark.parametrize("file_path", _get_definition_files())
def test_definition(file_path):
"""
Validate DeviceType definitions using the provided JSON schema.
Validate each DeviceType definition file using the provided JSON schema.
"""
# Check file extension
assert file_path.split('.')[-1] in ('yaml', 'yml'), f"Invalid file extension: {file_path}"
# Read file
with open(file_path) as definition_file:
definition = yaml.load(definition_file.read(), Loader=yaml.SafeLoader)
content = definition_file.read()
# Check for trailing newline
assert content[-1] == '\n', "Missing trailing newline"
# Load YAML data
definition = yaml.load(content, Loader=yaml.SafeLoader)
# Run validation
try: