Skip to content

🐛 sphinx-test-reports: test-env renders false, null, 0 and "" as empty cells, and true as True #2139

Description

@chrisjsewell

test-env builds a scalar cell with nodes.paragraph(text=cell) (test_env.py:220), and docutils' TextElement.__init__ adds the text only if text: (docutils/nodes.py:1517), so every FALSY value renders as an EMPTY cell, and a non-string is rendered through str(). Measured at e13ce72f with a tox-envreport-style file holding one environment of scalar values:

JSON value rendered Data cell
3, 1.5, 2.0, 1e16 3, 1.5, 2.0, 1e+16
true True
false (empty)
null (empty)
"" (empty)
0, 0.0 (by the same rule; not run) (empty)

A false flag and a null are the values a reader most wants to see, and they are indistinguishable from a missing one; True is Python's spelling, not the file's.

Proposal. Spell scalars as JSON (json.dumps(cell) for everything that is not a str): true / false / null / 0, and pass a str through verbatim — the same rule the list/dict branch already follows with json.dumps(indent=4).

ubCode's port spells scalars as JSON (useblocks/ubcode#3924).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Medium prioritybugpkg: sphinx-test-reportsConcerns the sphinx-test-reports package (packages/sphinx-test-reports)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions