Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to run python-code example in readme #38

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import re
from pathlib import Path

import pytest


def _parse_readme_examples():
lines = open(Path(__file__).parent.parent / "README.md").read().splitlines()

# use regex to find all python code blocks
code_blocks = re.findall(r"```python(.*?)```", "\n".join(lines), re.DOTALL)
leifdenby marked this conversation as resolved.
Show resolved Hide resolved

return code_blocks


@pytest.mark.parametrize("example", _parse_readme_examples())
def test_readme_example(example):
exec(example)
khintz marked this conversation as resolved.
Show resolved Hide resolved