Skip to content

Commit

Permalink
add skipfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nschloe committed Dec 11, 2021
1 parent fd18368 commit 07bfb8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ dolor sit amet.
````

Conditionally skipping code blocks works with `skipif`, e.g.,
```
```markdown
<!--pytest-codeblocks:skipif(sys.version_info <= (3, 7))-->
```

You can also skip all blocks in the entire file by putting
```markdown
<!--pytest-codeblocks:skipfile-->
```
in the first line.

#### Merging code blocks

Broken-up code blocks can be merged into one with the `pytest-codeblocks:cont` prefix
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pytest-codeblocks
version = 0.12.0
version = 0.12.1
author = Nico Schlömer
author_email = nico.schloemer@gmail.com
description = Test code blocks in your READMEs
Expand Down
4 changes: 4 additions & 0 deletions src/pytest_codeblocks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def extract_from_buffer(f, max_num_lines: int = 10000) -> list[CodeBlock]:

while True:
line = f.readline()

if k == 1 and line.strip() == "<!--pytest-codeblocks:skipfile-->":
return []

k += 1
if not line:
# EOF
Expand Down

0 comments on commit 07bfb8a

Please sign in to comment.