pytest-cov icon indicating copy to clipboard operation
pytest-cov copied to clipboard

RecursionError: maximum recursion depth exceeded with --cov-report=html

Open npow opened this issue 3 years ago • 5 comments

I tried generating a coverage report using pytest --cov-report=html --cov srmb and got RecursionError: maximum recursion depth exceeded:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/_pytest/main.py", line 257, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/_pytest/main.py", line 313, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pytest_cov/plugin.py", line 271, in pytest_runtestloop
INTERNALERROR>     self.cov_controller.finish()
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pytest_cov/engine.py", line 44, in ensure_topdir_wrapper
INTERNALERROR>     return meth(self, *args, **kwargs)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/pytest_cov/engine.py", line 188, in summary
INTERNALERROR>     total = self.cov.html_report(ignore_errors=True, directory=output)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/control.py", line 958, in html_report
INTERNALERROR>     return reporter.report(morfs)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/html.py", line 229, in report
INTERNALERROR>     self.incr.check_global_data(self.config, self.pyfile_html_source)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/html.py", line 454, in check_global_data
INTERNALERROR>     m.update(d)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/misc.py", line 232, in update
INTERNALERROR>     self.update(a)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/misc.py", line 232, in update
INTERNALERROR>     self.update(a)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/misc.py", line 232, in update
INTERNALERROR>     self.update(a)
INTERNALERROR>   [Previous line repeated 966 more times]
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/coverage/misc.py", line 228, in update
INTERNALERROR>     a = getattr(v, k)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/sure/__init__.py", line 1104, in method
INTERNALERROR>     builder = AssertionBuilder(name, negative=is_negative)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/sure/__init__.py", line 483, in __init__
INTERNALERROR>     self._that = AssertionHelper(self.obj)
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/sure/old.py", line 91, in __init__
INTERNALERROR>     if all_integers(within_range):
INTERNALERROR>   File "/Users/pownissa/anaconda3/lib/python3.7/site-packages/sure/old.py", line 57, in all_integers
INTERNALERROR>     if not is_iterable(obj):
INTERNALERROR> RecursionError: maximum recursion depth exceeded

Surprisingly, pytest --cov-report=xml --cov srmb works fine (but isn't that useful to me).

OS: MacOS Catalina 10.15.7 Python: 3.7.11 Output from pip list:

Package                Version   Location
---------------------- --------- ------------------------------------------------------------------------------------------------------------------------------------------------
antlr4-python3-runtime 4.8
asn1crypto             1.4.0
astroid                2.6.6
attrs                  20.3.0
awswrangler            2.11.0
beautifulsoup4         4.10.0
boto3                  1.21.8
botocore               1.24.8
certifi                2021.10.8
charset-normalizer     2.0.12
click                  8.0.4
coverage               6.3.2
Deprecated             1.2.13
dill                   0.3.4
et-xmlfile             1.1.0
filelock               3.6.0
fire                   0.4.0
flatten-dict           0.4.2
google-pasta           0.2.0
grpcio                 1.43.0
idna                   3.3
importlib-metadata     4.11.2
importlib-resources    5.4.0
iniconfig              1.1.1
isort                  5.10.1
Jinja2                 3.0.3
jmespath               0.10.0
joblib                 1.1.0
jsonschema             4.4.0
lazy-object-proxy      1.7.1
llvmlite               0.36.0
lxml                   4.8.0
MarkupSafe             2.1.0
mccabe                 0.6.1
metaflow               2.5.2     <redacted>
msgpack                1.0.3
multiprocess           0.70.12.2
numba                  0.53.1
numpy                  1.19.5
omegaconf              2.1.1
openpyxl               3.0.9
orjson                 3.6.4
packaging              21.3
pandas                 1.3.5
pathos                 0.2.8
pathspec               0.8.1
pg8000                 1.21.3
pip                    20.1.1
pipelinex              0.7.5
pluggy                 1.0.0
pox                    0.3.0
ppft                   1.6.6.4
protobuf               3.19.4
protobuf3-to-dict      0.1.5
py                     1.11.0
pyarrow                5.0.0
pydash                 5.1.0
PyICU                  2.8.1
pylint                 3.0.0a4
PyMySQL                1.0.2
pyparsing              3.0.7
pyrsistent             0.18.1
pytest                 7.1.1
pytest-allclose        1.0.0
pytest-cov             3.0.0
python-dateutil        2.8.2
PyTrie                 0.4.0
pytz                   2021.3
PyYAML                 6.0
ray                    1.11.0
redis                  4.1.4
redshift-connector     2.0.904
requests               2.27.1
s3transfer             0.5.2
sagemaker              2.77.1
scikit-learn           0.24.1
scipy                  1.7.3
scramp                 1.4.1
setuptools             47.1.0
six                    1.16.0
smdebug-rulesconfig    1.0.1
sortedcontainers       2.4.0
soupsieve              2.3.1
tempenv                2.0.0
tenacity               8.0.1
termcolor              1.1.0
threadpoolctl          3.1.0
toml                   0.10.2
tomli                  2.0.1
tqdm                   4.62.3
typed-ast              1.4.3
typing-extensions      4.1.1
urllib3                1.26.8
vsot                   0.1.4
wrapt                  1.12.1
zipp                   3.7.0

npow avatar Mar 20 '22 00:03 npow

I also have same issue while generating HTML coverage report. XML is working fine. Please check the issue. As alternative, right now using coverage html -d coverage_html to generate HTML report.

rakeshrathod1809 avatar Apr 22 '22 11:04 rakeshrathod1809

Can either of you provide a reproducible case?

@rakeshrathod1809 I don't understand how adding the -d option to the html command could have an effect. Can you provide the full error report you are seeing?

nedbat avatar Apr 22 '22 15:04 nedbat

@npow it would appear that you have https://github.com/gabrielfalcao/sure installed but it's not in the package list. Does this problem reproduce with either assertion rewriting disabled (--assert=plain) or sure uninstalled?

ionelmc avatar Apr 22 '22 15:04 ionelmc

@nedbat I am having issue with pytest tests --cov=app --cov-report=html. Regarding coverage html -d coverage_html, I am using it as an alternative to generate HTML reports from the .coverage file generated by pytest. And it's working properly. I have mentioned it just for reference.

Please find the error report below.

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\_pytest\main.py", line 268, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\_pytest\main.py", line 322, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\pluggy\_callers.py", line 55, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\pytest_cov\plugin.py", line 303, in pytest_runtestloop
INTERNALERROR>     self.cov_total = self.cov_controller.summary(self.cov_report)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\pytest_cov\engine.py", line 44, in ensure_topdir_wrapper
INTERNALERROR>     return meth(self, *args, **kwargs)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\pytest_cov\engine.py", line 189, in summary
INTERNALERROR>     total = self.cov.html_report(ignore_errors=True, directory=output)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\control.py", line 1028, in html_report
INTERNALERROR>     ret = reporter.report(morfs)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\html.py", line 205, in report
INTERNALERROR>     self.incr.check_global_data(self.config, self.pyfile_html_source)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\html.py", line 447, in check_global_data
INTERNALERROR>     m.update(d)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\misc.py", line 255, in update
INTERNALERROR>     self.update(a)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\misc.py", line 255, in update
INTERNALERROR>     self.update(a)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\misc.py", line 255, in update
INTERNALERROR>     self.update(a)
INTERNALERROR>   [Previous line repeated 964 more times]
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\coverage\misc.py", line 251, in update
INTERNALERROR>     a = getattr(v, k)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\sure\__init__.py", line 1104, in method
INTERNALERROR>     builder = AssertionBuilder(name, negative=is_negative)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\sure\__init__.py", line 483, in __init__
INTERNALERROR>     self._that = AssertionHelper(self.obj)
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\sure\old.py", line 91, in __init__
INTERNALERROR>     if all_integers(within_range):
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\sure\old.py", line 57, in all_integers
INTERNALERROR>     if not is_iterable(obj):
INTERNALERROR>   File "E:\Projects\AWS_Demo\homek-alexa-lambda\.venv\lib\site-packages\sure\old.py", line 53, in is_iterable
INTERNALERROR>     return hasattr(obj, '__iter__') and not isinstance(obj, string_types)
INTERNALERROR> RecursionError: maximum recursion depth exceeded while calling a Python object

rakeshrathod1809 avatar Apr 22 '22 16:04 rakeshrathod1809

@ionelmc and @nedbat One more observation based on comment of @ionelmc. I have just commented sure in my code and it's working properly. With sure, there is issue. i.e. uninstalling sure is working properly.

Same issue with --assert=plain - Not working.

rakeshrathod1809 avatar Apr 22 '22 16:04 rakeshrathod1809