-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added test for is_supported_codeblock
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |