Skip to content

Commit 867bd00

Browse files
committed
Correct and test json data
1 parent 99a1e74 commit 867bd00

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,13 @@ This markdown could be fully tested like this
134134

135135
```python
136136
import pathlib
137-
import pytest
138137

139138
from mktestdocs import check_md_file
140139

141140
fpath = pathlib.Path("docs") / "bash-support.md"
142141

143-
def test_python_examples():
144-
check_md_file(fpath=fpath, lang="python")
145-
146-
def test_bash_examples():
147-
check_md_file(fpath=fpath, lang="bash")
142+
check_md_file(fpath=fpath, lang="python")
143+
check_md_file(fpath=fpath, lang="bash")
148144
```
149145

150146
## Additional Language Support
@@ -168,16 +164,12 @@ You could create a json validator that tested the example was always valid json
168164
import json
169165
import pathlib
170166

171-
import pytest
172-
173167
from mktestdocs import check_md_file, register_executor
174168

175169
def parse_json(json_text):
176170
json.loads(json_text)
177171

178172
register_executor("json", parse_json)
179173

180-
def test_files_good(fpath):
181-
fpath = pathlib.Path("docs") / "additional-language-support.md"
182-
check_md_file(fpath=fpath)
174+
check_md_file(fpath=pathlib.Path("docs") / "additional-language-support.md", lang="json")
183175
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
This is an example REST response
22

3-
```json
4-
{body: {results: [spam, eggs]}, errors: []}
3+
```json
4+
{"body": {"results": ["spam", "eggs"]}, "errors": []}
55
```

0 commit comments

Comments
 (0)