Skip to content

Commit

Permalink
test: added test for is_supported_codeblock
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Oct 30, 2023
1 parent 7cf8acd commit c1ba742
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from gptme.tools import is_supported_codeblock


def test_is_supported_codeblock():
block_plain = """```
some plaintext
```
"""
# clean unsupported block
assert not is_supported_codeblock(block_plain)

block_python = """```python
print("hello world")
```
"""
# clean supported block
assert is_supported_codeblock(block_python)

# has preamble
s = f"""bla bla\n{block_python}"""
assert is_supported_codeblock(s)

# last block is plain/unsupported
s = f"""bla bla\n{block_python}\nbla bla{block_plain}"""
assert not is_supported_codeblock(s)

0 comments on commit c1ba742

Please sign in to comment.