Skip to content

Commit

Permalink
Don't report an error when parsing an empty annotations file
Browse files Browse the repository at this point in the history
Fixes: #64
  • Loading branch information
Gagi2k committed Jan 27, 2022
1 parent 4a5416e commit 7b5f67f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qface/generator.py
Expand Up @@ -344,7 +344,11 @@ def merge_annotations(system, document):
if not Path(document).exists():
return
meta = FileSystem.load_yaml(document)
click.secho('merge: {0}'.format(document.name), fg='blue')
if not meta:
click.secho('skipping empty: {0}'.format(document.name), fg='blue')
return
else:
click.secho('merge: {0}'.format(document.name), fg='blue')
try:
for identifier, data in meta.items():
symbol = system.lookup(identifier)
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions tests/test_tags.py
Expand Up @@ -68,6 +68,16 @@ def test_merge_annotation():
FileSystem.merge_annotations(system, inputPath / 'tuner_annotations.yaml')
assert interface.attribute('extra', 'extraA') is True

@patch('sys.stderr', new_callable=StringIO)
def test_merge_empty_annotation(mock_stderr):
system = loadTuner()
interface = system.lookup('com.pelagicore.ivi.tuner.Tuner')
assert interface
FileSystem.merge_annotations(system, inputPath / 'empty_tuner_annotations.yaml')

assert interface.attribute('extra', 'extraA') is None
assert not mock_stderr.getvalue().__contains__("Error parsing annotation")

@patch('sys.stderr', new_callable=StringIO)
def test_merge_broken_annotation(mock_stderr):
system = loadTuner()
Expand Down

0 comments on commit 7b5f67f

Please sign in to comment.