Update test_try_fix_yaml.py

test extract snippet with prefix "```" or "```yml"
This commit is contained in:
Xinyu Wu 2025-11-07 15:43:28 +08:00 committed by GitHub
parent 3e9b15de15
commit 46f889b314
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,16 +21,34 @@ class TestTryFixYaml:
# The function extracts YAML snippet
def test_extract_snippet(self):
review_text = '''\
review_text1 = '''\
Here is the answer in YAML format:
```yaml
name: John Smith
age: 35
```
'''
review_text2 = '''\
Here is the answer in YAML format:
```yml
name: John Smith
age: 35
```
'''
review_text3 = '''\
Here is the answer in YAML format:
```
name: John Smith
age: 35
```
'''
expected_output = {'name': 'John Smith', 'age': 35}
assert try_fix_yaml(review_text) == expected_output
assert try_fix_yaml(review_text1) == expected_output
assert try_fix_yaml(review_text2) == expected_output
assert try_fix_yaml(review_text3) == expected_output
# The YAML string is empty.