cannot create an xml report · Issue #1709 · nedbat/coveragepy (original) (raw)
Describe the bug
I create the coverage of some tests by calling the coverage API according to the documentation, then pytest.main(...
etc according to the documentation
import coverage
running the application under /my
but my plugin code is under my_envs/my_model
cov = coverage.Coverage( source=['/my_envs/my_model'], messages=True ) cov.start()
pytest.main(...)
cov.stop() cov.save()
works
cov.report()
works
cov.html_report()
ERROR: does not work
cov.xml_report(outfile="coverage.xml")
The html report works perfectly, the stdout terminal also works...
the xml_report crashes, then tried the terminal way: coverage xml -o coverage.xml
to convert the existing .coverage file to xml, same issue as with the function xml_report:
Traceback (most recent call last):
File "/home/my_user/.local/bin/coverage", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/my_user/.local/lib/python3.11/site-packages/coverage/cmdline.py", line 973, in main
status = CoverageScript().command_line(argv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/my_user/.local/lib/python3.11/site-packages/coverage/cmdline.py", line 733, in command_line
total = self.coverage.xml_report(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/my_user/.local/lib/python3.11/site-packages/coverage/control.py", line 1215, in xml_report
return render_report(self.config.xml_output, XmlReporter(self), morfs, self._message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/my_user/.local/lib/python3.11/site-packages/coverage/report_core.py", line 61, in render_report
ret = reporter.report(morfs, outfile=outfile)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/my_user/.local/lib/python3.11/site-packages/coverage/xmlreport.py", line 130, in report
for _, class_elt in human_sorted_items(pkg_data.elements.items()):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/my_user/.local/lib/python3.11/site-packages/coverage/misc.py", line 377, in human_sorted_items
return sorted(items, key=lambda item: (_human_key(item[0]), *item[1:]), reverse=reverse)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'Element' and 'Element'
To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:
- What version of Python are you using?
3.11.6 - What version of coverage.py shows the problem? The output of
coverage debug sys
is helpful.
-- sys -------------------------------------------------------
coverage_version: 7.3.2
coverage_module: /home/my_user/.local/lib/python3.11/site-packages/coverage/__init__.py
tracer: -none-
CTracer: available
plugins.file_tracers: -none-
plugins.configurers: -none-
plugins.context_switchers: -none-
configs_attempted: .coveragerc
setup.cfg
tox.ini
pyproject.toml
configs_read: -none-
config_file: None
config_contents: -none-
data_file: -none-
python: 3.11.6 (main, Nov 29 2023, 04:47:02) [GCC 10.2.1 20210110]
platform: Linux-6.1.0-13-amd64-x86_64-with-glibc2.31
implementation: CPython
executable: /usr/local/bin/python
def_encoding: utf-8
fs_encoding: utf-8
pid: 174
cwd: /my
path: /home/my_user/.local/bin
/usr/local/lib/python311.zip
/usr/local/lib/python3.11
/usr/local/lib/python3.11/lib-dynload
/home/my_user/.local/lib/python3.11/site-packages
/usr/local/lib/python3.11/site-packages
environment: HOME = /home/my_user
PYTHON_GET_PIP_SHA256 = 9cc01665956d22b3bf057ae8287b035827bfd895da235bcea200ab3b811790b6
PYTHON_GET_PIP_URL = https://github.com/pypa/get-pip/raw/4cfa4081d27285bda1220a62a5ebf5b4bd749cdb/public/get-pip.py
PYTHON_PIP_VERSION = 23.2.1
PYTHON_SETUPTOOLS_VERSION = 65.5.1
PYTHON_VERSION = 3.11.6
command_line: /home/my_user/.local/bin/coverage debug sys
sqlite3_sqlite_version: 3.34.1
sqlite3_temp_store: 0
sqlite3_compile_options: COMPILER=gcc-10.2.1 20210110, ENABLE_COLUMN_METADATA, ENABLE_DBSTAT_VTAB,
ENABLE_FTS3, ENABLE_FTS3_PARENTHESIS, ENABLE_FTS3_TOKENIZER, ENABLE_FTS4,
ENABLE_FTS5, ENABLE_JSON1, ENABLE_LOAD_EXTENSION, ENABLE_PREUPDATE_HOOK,
ENABLE_RTREE, ENABLE_SESSION, ENABLE_STMTVTAB, ENABLE_UNLOCK_NOTIFY,
ENABLE_UPDATE_DELETE_LIMIT, HAVE_ISNAN, LIKE_DOESNT_MATCH_BLOBS,
MAX_SCHEMA_RETRY=25, MAX_VARIABLE_NUMBER=250000, OMIT_LOOKASIDE,
SECURE_DELETE, SOUNDEX, TEMP_STORE=1, THREADSAFE=1, USE_URI
- What versions of what packages do you have installed? The output of
pip freeze
is helpful.
annotated-types==0.6.0
anyio==4.1.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
asgiref==3.7.2
astroid==3.0.1
attrs==23.1.0
Babel==2.13.1
bcrypt==4.1.1
Cerberus==1.3.5
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
contextlib2==21.6.0
coverage==7.3.2
cryptography==41.0.7
cx-Oracle==8.3.0
dill==0.3.7
distlib==0.3.7
Django==4.2.7
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.0
docopt==0.6.2
drf-spectacular==0.26.5
environs==9.5.0
et-xmlfile==1.1.0
ghp-import==2.1.0
gitdb==4.0.11
GitPython==3.1.40
graphviz==0.20.1
gunicorn==21.2.0
h11==0.14.0
httpcore==1.0.2
httpx==0.25.2
idna==3.6
inflection==0.5.1
iniconfig==2.0.0
isodate==0.6.1
isort==5.13.0
jedi==0.19.1
Jinja2==3.1.2
jsonschema==4.20.0
jsonschema-specifications==2023.11.1
lxml==4.9.3
Markdown==3.5.1
MarkupSafe==2.1.3
marshmallow==3.20.1
mccabe==0.7.0
mergedeep==1.3.4
minio==7.2.0
mkdocs==1.5.3
mkdocs-material==9.4.11
mkdocs-material-extensions==1.3.1
mkdocs-render-swagger-plugin==0.1.1
mssql-django==1.3
openpyxl==3.1.2
outcome==1.3.0.post0
packaging==23.2
page-objects==1.1.0
paginate==0.5.6
paramiko==3.3.1
parso==0.8.3
pathspec==0.11.2
pem==23.1.0
pep517==0.13.1
Pillow==10.1.0
pip-api==0.0.30
pipreqs==0.4.13
platformdirs==4.0.0
plette==0.4.4
pluggy==1.3.0
psutil==5.9.6
psycopg2==2.9.9
py-markdown-table==0.4.0
pyasn1==0.5.1
pycparser==2.21
pycryptodome==3.19.0
pydantic==2.5.2
pydantic_core==2.14.5
pygit2==1.13.3
Pygments==2.17.2
PyJWT==2.8.0
pylint==3.0.2
pymdown-extensions==10.5
PyNaCl==1.5.0
pyodbc==5.0.1
pysftp==0.2.9
pysmb==1.2.9.1
PySocks==1.7.1
pytest==7.4.3
pytest-cov==4.1.0
python-box==7.1.1
python-dateutil==2.8.2
python-dotenv==1.0.0
pytz==2023.3.post1
PyYAML==6.0.1
pyyaml_env_tag==0.1
referencing==0.31.0
regex==2023.10.3
reportlab==4.0.7
requests==2.31.0
requests-file==1.5.1
requests-toolbelt==1.0.0
requirementslib==3.0.0
rpds-py==0.13.1
schema==0.7.5
selenium==4.16.0
setproctitle==1.3.3
sh==2.0.6
six==1.16.0
smmap==5.0.1
sniffio==1.3.0
sortedcontainers==2.4.0
sqlparse==0.4.4
tomlkit==0.12.3
tqdm==4.66.1
trio==0.23.1
trio-websocket==0.11.1
typing_extensions==4.9.0
uritemplate==4.1.1
urllib3==2.1.0
validators==0.22.0
watchdog==3.0.0
webcolors==1.13
whitenoise==6.6.0
wsproto==1.2.0
xlrd==2.0.1
yarg==0.1.9
zeep==4.2.1
- What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
its clients code, that I can't share
Expected behavior
the coverage.xml file exists, no errors