Skip to content

Commit 8e20f3e

Browse files
authored
Merge pull request #69 from nschloe/skipfile
add skipfile
2 parents fd18368 + 07bfb8a commit 8e20f3e

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,16 @@ dolor sit amet.
6363
````
6464

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

70+
You can also skip all blocks in the entire file by putting
71+
```markdown
72+
<!--pytest-codeblocks:skipfile-->
73+
```
74+
in the first line.
75+
7076
#### Merging code blocks
7177

7278
Broken-up code blocks can be merged into one with the `pytest-codeblocks:cont` prefix

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pytest-codeblocks
3-
version = 0.12.0
3+
version = 0.12.1
44
author = Nico Schlömer
55
author_email = nico.schloemer@gmail.com
66
description = Test code blocks in your READMEs

src/pytest_codeblocks/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def extract_from_buffer(f, max_num_lines: int = 10000) -> list[CodeBlock]:
3636

3737
while True:
3838
line = f.readline()
39+
40+
if k == 1 and line.strip() == "<!--pytest-codeblocks:skipfile-->":
41+
return []
42+
3943
k += 1
4044
if not line:
4145
# EOF

0 commit comments

Comments
 (0)