Skip to content

Commit adc8312

Browse files
authored
Added testing (#11)
1 parent d0cf333 commit adc8312

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ jobs:
3333
with:
3434
python-version: ${{ matrix.python-version }}
3535

36+
- name: Install dependencies
37+
run: python -m pip install pytest-xdist
38+
3639
- name: Install package
3740
run: python -m pip install .[test]
3841

3942
- name: Test package
40-
run: python -m pytest
43+
run: python -m pytest --forked
4144

4245

4346

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,21 @@ py::class_<MyClass>(m, "MyClass", DOC(MyClass))
7878

7979
This tool supports Linux and macOS and requires Clang/LLVM to be installed. It
8080
has never been used on Windows and will likely require adaptations.
81+
82+
83+
## Testing
84+
85+
Install package `pytest-xdist`:
86+
```
87+
python3 -m pip install pytest-xdist
88+
```
89+
90+
Install the library:
91+
```
92+
python3 -m pip install .
93+
```
94+
95+
And execute the tests (forked)
96+
```
97+
python3 -m pip pytest --forked
98+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Senectus et netus et malesuada fames ac. Tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius.
3+
* @param x - Begin first parameter description. Senectus et netus et malesuada fames ac. End first parameter description.
4+
*/
5+
void longParameterDescription(int x);

tests/long_parameter_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import collections
2+
import os
3+
import time
4+
import sysconfig
5+
import sys
6+
7+
import pytest
8+
9+
import pybind11_mkdoc
10+
11+
DIR = os.path.abspath(os.path.dirname(__file__))
12+
13+
def test_long_parameter(capsys):
14+
comments = pybind11_mkdoc.mkdoc_lib.extract_all([os.path.join(DIR, "long_parameter_docs", "long_parameter.h")])
15+
pybind11_mkdoc.mkdoc_lib.write_header(comments, sys.stdout)
16+
17+
res = capsys.readouterr()
18+
expected = """\
19+
Parameter ``x``:
20+
- Begin first parameter description. Senectus et netus et
21+
malesuada fames ac. End first parameter description.)doc";
22+
"""
23+
24+
print(res.out)
25+
assert expected in res.out
26+

tests/sample_header_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ def test_generate_headers(capsys):
6666
#endif
6767
6868
"""
69-
69+

0 commit comments

Comments
 (0)