Skip to content

Commit b5cc054

Browse files
committed
ENH: Make new pytest work (better) and properly support pytest.skip()
This hsould be backwards compatible, but I didn't properly test it. I realized that version 0.2 existed (but not in the main repo), so bumping to 0.3 now, although it should be harmless fixes with no meaningful behavior change.
1 parent 13ea633 commit b5cc054

File tree

5 files changed

+210
-167
lines changed

5 files changed

+210
-167
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ fail to report, which causes test failures.
6565

6666
The first version effectively ignored the ``--errors-for-leak-kinds`` valgrind
6767
option. In the current version ``--errors-for-leak-kinds=definite`` will work
68-
(and ignore "indirect" leaks).
68+
(and ignore "indirect" leaks), but you must still pass
69+
``--show-leak-kinds=definite`` it appears.
6970

7071
Any valgrind error or memory leak occuring *during* the test will lead to the
7172
test being recorded as *FAILURE*. You will have to search the valgrind log
7273
file for the specific error.
7374

74-
As a further example, one may run an individual NumPy test file with the following
75-
commend (some of these options are not necessary):
76-
```
77-
PYTHONMALLOC=malloc valgrind --show-leak-kinds=definite --log-file=/tmp/valgrind-output python runtests.py -g -t numpy/core/tests/test_dtype.py -- -vv --valgrind --valgrind-log=/tmp/valgrind-output --continue-on-collection-errors
78-
```
75+
When running this on a module it makes sense to compile with debug symbols
76+
usually a ``-g`` option.
77+
For example to run on NumPy, it is also necessary to use:
78+
``--continue-on-collection-errors`` since some tests fail during collection
79+
otherwise. (This is due to missing support for longdoubles or floating point
80+
errors.)
81+
7982

8083
### Options
8184

@@ -101,6 +104,7 @@ You can mark tests with `pytest.mark.valgrind_known_leak(reason="?!")`
101104
or `pytest.mark.valgrind_known_error(reason="Oooops")` (or both) to make the test result
102105
an `xfail` specifically for this plugin and specific to either leaks or other errors
103106
reported by valgrind.
107+
These are, however, currently not defined by the plugin (not sure if they should).
104108

105109
Not all errors are necessarily due to your own code, sometimes false positives can be reported
106110
from known good functions. For example `strcmp` can do this if the valgrind suppressions are not

example/test_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def test_all_good():
2121
# This test just passes, yay!
2222
pass
2323

24+
def test_skipped():
25+
# This test is skipped via exception, keep the skip
26+
pytest.skip()
2427

2528
def test_fails_but_valgrind_good():
2629
assert 0
@@ -60,4 +63,4 @@ def test_valgrind_leak_ignored_but_errors_as_well():
6063

6164
def test_another_good_test():
6265
# Just to show that the old leaks are obviously not still found.
63-
pass
66+
pass

0 commit comments

Comments
 (0)