abalkin / pytest-leaks

A pytest plugin to trace resource leaks.
https://abalkin.github.io/pytest-leaks
Other
115 stars 4 forks source link

Doctest test false positive when inside run inside pytest testdir #12

Open pv opened 5 years ago

pv commented 5 years ago

The test tests/test_refleaks.py:test_doctest checks for leaks, but it gives a false positive if the line >>> items.append(SomeClass()) that adds stuff to a global variable is replaced just by >>> SomeClass().

Interestingly, when run outside the pytest testdir framework it works:

cat <<EOF > test_foo.py
class SomeClass(object):
    '''
    >>> SomeClass()
    <...
    '''
EOF
python3 -mpytest --doctest-modules -R : test_foo.py
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /home/pauli/prj/scipy/pytest-leaks
plugins: leaks-0.3.0
collected 1 item                                                               

test_foo.py .                                                            [100%]

=========================== 1 passed in 0.16 seconds ===========================

Similar difference vs. runpytest and runpytest_subprocess appears also in our other test cases.