From 3f76d954950083dbd3a8cfd256ee515d72cd64cf Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 20 Nov 2023 10:35:35 +0200 Subject: [PATCH] ScannerError --- tests/unittest/test_load_yaml.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unittest/test_load_yaml.py b/tests/unittest/test_load_yaml.py index e4db85ab..a77c847b 100644 --- a/tests/unittest/test_load_yaml.py +++ b/tests/unittest/test_load_yaml.py @@ -2,6 +2,9 @@ # Generated by CodiumAI import pytest +import yaml +from yaml.scanner import ScannerError + from pr_agent.algo.utils import load_yaml @@ -28,6 +31,9 @@ PR Feedback: suggestion: Consider using a more descriptive variable name than 'user' for the command prompt. A more descriptive name would make the code more readable and maintainable. [medium] relevant line: user="""PR Info: aaa Security concerns: No''' + with pytest.raises(ScannerError): + yaml.safe_load(yaml_str) + expected_output = {'PR Analysis': {'Main theme': 'Enhancing the `/describe` command prompt by adding title and description', 'Type of PR': 'Enhancement', 'Relevant tests added': False, 'Focused PR': 'Yes, the PR is focused on enhancing the `/describe` command prompt.'}, 'PR Feedback': {'General suggestions': 'The PR seems to be well-structured and focused on a specific enhancement. However, it would be beneficial to add tests to ensure the new feature works as expected.', 'Code feedback': [{'relevant file': 'pr_agent/settings/pr_description_prompts.toml', 'suggestion': "Consider using a more descriptive variable name than 'user' for the command prompt. A more descriptive name would make the code more readable and maintainable. [medium]", 'relevant line': 'user="""PR Info: aaa'}], 'Security concerns': False}} assert load_yaml(yaml_str) == expected_output @@ -36,6 +42,9 @@ PR Feedback: - relevant file: src/app.py: suggestion content: The print statement is outside inside the if __name__ ==: \ ''' + with pytest.raises(ScannerError): + yaml.safe_load(yaml_str) + expected_output =[{'relevant file': 'src/app.py:', 'suggestion content': 'The print statement is outside inside the if __name__ ==: '}] assert load_yaml(yaml_str) == expected_output