Skip to content

Commit 87cefe6

Browse files
author
Paul Gauthier
committed
aider: Add a test that cycles through all the PARSERS values and calls get_parser on them.
# Aider chat conversation: USER: add a test that cycles through all the `PARSERS` values and does get_parser on them ASSISTANT: To add a test that cycles through all the `PARSERS` values and calls `filename_to_lang` on them, we need to modify the `tests/test_parsers.py` file. Here is the step-by-step process: 1. Import the `PARSERS` dictionary and `filename_to_lang` function from `parsers.py` in `test_parsers.py`. 2. ^C KeyboardInterrupt USER: I added these *read-write* files: /Users/gauthier/Projects/grep-ast/grep_ast/grep_ast.py ASSISTANT: To add a test that cycles through all the `PARSERS` values and calls `get_parser` on them, we need to modify the `tests/test_parsers.py` file. Here is the step-by-step process: 1. Import the `PARSERS` dictionary and `get_parser` function from `parsers.py` in `test_parsers.py`. 2. Create a new test function, let's call it `test_get_parser_for_all_parsers`. 3. Inside this function, iterate over all the values in the `PARSERS` dictionary. 4. For each value, call the `get_parser` function and assert that it does not return `None`. Here is the *SEARCH/REPLACE block* for the changes: ```python tests/test_parsers.py <<<<<<< SEARCH ======= import pytest from grep_ast.parsers import PARSERS, get_parser def test_get_parser_for_all_parsers(): for lang in PARSERS.values(): assert get_parser(lang) is not None >>>>>>> REPLACE ``` This test will fail if `get_parser` returns `None` for any language in the `PARSERS` dictionary, indicating that there is no parser available for that language.
1 parent 07a5fe4 commit 87cefe6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/test_parsers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
from grep_ast.parsers import PARSERS, get_parser
3+
4+
def test_get_parser_for_all_parsers():
5+
for lang in PARSERS.values():
6+
assert get_parser(lang) is not None

0 commit comments

Comments
 (0)