mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-21 19:09:13 +00:00
Tools: Add unit tests for idf.py hints
This commit is contained in:
committed by
Roland Dobai
parent
4905fbff32
commit
92ef2a4c83
35
tools/test_idf_py/test_hints.py
Executable file
35
tools/test_idf_py/test_hints.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import yaml
|
||||
|
||||
CWD = os.path.join(os.path.dirname(__file__))
|
||||
ERR_OUT_YML = os.path.join(CWD, 'error_output.yml')
|
||||
|
||||
try:
|
||||
from idf_py_actions.tools import generate_hints
|
||||
except ImportError:
|
||||
sys.path.append(os.path.join(CWD, '..'))
|
||||
from idf_py_actions.tools import generate_hints
|
||||
|
||||
|
||||
class TestHintsMassages(unittest.TestCase):
|
||||
def test_output(self) -> None:
|
||||
with open(ERR_OUT_YML) as f:
|
||||
error_output = yaml.safe_load(f)
|
||||
for error, hint in error_output.items():
|
||||
with tempfile.NamedTemporaryFile(mode='w') as f:
|
||||
f.write(error)
|
||||
f.flush()
|
||||
for generated_hint in generate_hints(f.name):
|
||||
self.assertEqual(generated_hint, hint)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user