diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4c957c78..fbf71742e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/tests/test_definitions.py b/tests/test_definitions.py index 5cc4cc219..8898a4b04 100644 --- a/tests/test_definitions.py +++ b/tests/test_definitions.py @@ -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: