Skip to content

html report "pretty_file" prevents browser search #2170

@valumapps

Description

@valumapps

Describe the bug
When outputting html coverage, a user will try to use browser builtin search to find a file, but the search will fail to find the desired file.

To Reproduce

Answer the questions below:

  1. What version of Python are you using? python3.13
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
  3. What commands should we run to reproduce the problem?
  • run coverage html
  • then open htmlcov/index.html
  • in browser, type ctrl-f (or / depending on your browser)
  • type a file path that is present in the page, e.g. foo/bar/baz.py
  • the file is not found, when looking in page, it seems there are spaces in name
  • type instead foo<space character>/<space character>bar<space character>/<space character>baz.py
  • still not found

Expected behavior
The file should be found in browser search

Additional context
The problem is that coverage html outputs "fancy" unicode characters that nobody can type:

return re.sub(r"[/\\]", "\N{THIN SPACE}\\g<0>\N{THIN SPACE}", filename)

it makes browser search unusable and it's tedious to find a file when there are hundreds of source files

best thing would be to plain remove the spaces but if you insist on keeping spaces, there are alternatives:

  • use regular U+0020 spaces
  • don't put spaces but use css to add spacing around slashes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions