Skip to content

--doctest-modules causes py.test to consume all memory and then crash #3456

@tadams42

Description

@tadams42

WARNING: Please don't run code sample from below, it can block / crash your machine. Instead, use Vagrant machine for testing it.

So, on Ubuntu 17.10 , Python 3.6:

mkdir foobar
cd foobar
mkdir src
mkdir tests
mkdir docs
python3 -mvenv .venv
source .venv/bin/activate
pip install -U pip wheel
pip install "pytest>=3.0.0"

cat <<EOT > setup.cfg
[tool:pytest]
norecursedirs = .git tmp* .hg .venv .tox .eggs
testpaths = tests docs src
addopts =
    -r=xEfsw
    --strict
    --ignore=docs/conf.py
    --ignore=setup.py
    --ignore=.eggs
    --doctest-modules
    --doctest-glob=*.rst
    --tb=short
    --color=auto
EOT

echo "from unittest.mock import Mock, call" > tests/test_with_mock_package.py

Running py.test will cause it to consume all RAM it can get and then either kernel will kill it or system will start swapping wildly until it blocks completely.

To make above thing work:

--- setup.cfg   2018-05-08 13:03:47.058679203 +0000
+++ setup.cfg.new       2018-05-08 13:09:46.650678324 +0000
@@ -7,7 +7,7 @@
     --ignore=docs/conf.py
     --ignore=setup.py
     --ignore=.eggs
-    --doctest-modules
+    # --doctest-modules
     --doctest-glob=*.rst
     --tb=short
     --color=auto

After which:

$ py.test
============================================================ test session starts ============================================================
platform linux -- Python 3.6.3, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/vagrant/foobar, inifile: setup.cfg
collected 0 items

======================================================= no tests ran in 0.01 seconds ========================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: doctestsrelated to the doctests builtin plugin

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions