Skip to content

Commit

Permalink
Update README test
Browse files Browse the repository at this point in the history
  • Loading branch information
Artucuno committed Jan 28, 2024
1 parent f0aafcc commit 2595539
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ result = spam_repository.find_one_by_id(spam.id)

# Find One By Id using string if the id attribute is a ObjectIdField
result = spam_repository.find_one_by_id(ObjectId('611827f2878b88b49ebb69fc'))
assert result.foo.count == 2

# Find One By Query
result = spam_repository.find_one_by({'foo.count': 1})
Expand Down
12 changes: 10 additions & 2 deletions integration_test/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
import io
import os
import re
import sys

# This test isn't really nessessary

def extract_python_snippets(content):
# Regular expression pattern for finding Python code blocks
pattern = r'```python(.*?)```'
snippets = re.findall(pattern, content, re.DOTALL)

return snippets


def evaluate_snippet(snippet):
# Capture the output of the snippet
output_buffer = io.StringIO()
with contextlib.redirect_stdout(output_buffer):
exec(snippet, globals())
try:
exec(snippet, globals())
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
raise Exception(f"{e} {exc_type} {fname} {exc_tb.tb_lineno}")
return output_buffer.getvalue()


Expand Down

0 comments on commit 2595539

Please sign in to comment.