-
-
Notifications
You must be signed in to change notification settings - Fork 456
Closed
Labels
Description
Describe the bug
Generated html coverage report of file with f-string with double curly brackets like: f"{{this is not interpolated}}"
is wrongly rendered by removing one set of bracket.
To Reproduce
- What version of Python are you using?
Python 3.13.3
- What version of coverage.py shows the problem?
Coverage.py, version 7.8.2 with C extension
coverage debug sys
-- sys -------------------------------------------------------
coverage_version: 7.8.2
coverage_module: D:\Temp\python_coverage\.venv\Lib\site-packages\coverage\__init__.py
core: -none-
CTracer: available from D:\Temp\python_coverage\.venv\Lib\site-packages\coverage\tracer.cp313-win_amd64.pyd
plugins.file_tracers: -none-
plugins.configurers: -none-
plugins.context_switchers: -none-
configs_attempted: D:\Temp\python_coverage\.coveragerc
D:\Temp\python_coverage\setup.cfg
D:\Temp\python_coverage\tox.ini
D:\Temp\python_coverage\pyproject.toml
configs_read: -none-
config_file: None
config_contents: -none-
data_file: -none-
python: 3.13.3 (tags/v3.13.3:6280bb5, Apr 8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)]
platform: Windows-10-10.0.19045-SP0
implementation: CPython
gil_enabled: True
executable: D:\Temp\python_coverage\.venv\Scripts\python.exe
def_encoding: utf-8
fs_encoding: utf-8
pid: 6600
cwd: D:\Temp\python_coverage
path: D:\Temp\python_coverage\.venv\Scripts\coverage.exe
C:\Python313\python313.zip
C:\Python313\DLLs
C:\Python313\Lib
C:\Python313
D:\Temp\python_coverage\.venv
D:\Temp\python_coverage\.venv\Lib\site-packages
environment: TEMP = C:\Users\mgouin\AppData\Local\Temp
TMP = C:\Users\mgouin\AppData\Local\Temp
command_line: D:\Temp\python_coverage\.venv\Scripts\coverage debug sys
sqlite3_sqlite_version: 3.49.1
sqlite3_temp_store: 0
sqlite3_compile_options: ATOMIC_INTRINSICS=0, COMPILER=msvc-1943, DEFAULT_AUTOVACUUM,
DEFAULT_CACHE_SIZE=-2000, DEFAULT_FILE_FORMAT=4,
DEFAULT_JOURNAL_SIZE_LIMIT=-1, DEFAULT_MMAP_SIZE=0, DEFAULT_PAGE_SIZE=4096,
DEFAULT_PCACHE_INITSZ=20, DEFAULT_RECURSIVE_TRIGGERS,
DEFAULT_SECTOR_SIZE=4096, DEFAULT_SYNCHRONOUS=2,
DEFAULT_WAL_AUTOCHECKPOINT=1000, DEFAULT_WAL_SYNCHRONOUS=2,
DEFAULT_WORKER_THREADS=0, DIRECT_OVERFLOW_READ, ENABLE_FTS3, ENABLE_FTS4,
ENABLE_FTS5, ENABLE_MATH_FUNCTIONS, ENABLE_RTREE, MALLOC_SOFT_LIMIT=1024,
MAX_ATTACHED=10, MAX_COLUMN=2000, MAX_COMPOUND_SELECT=500,
MAX_DEFAULT_PAGE_SIZE=8192, MAX_EXPR_DEPTH=1000, MAX_FUNCTION_ARG=1000,
MAX_LENGTH=1000000000, MAX_LIKE_PATTERN_LENGTH=50000,
MAX_MMAP_SIZE=0x7fff0000, MAX_PAGE_COUNT=0xfffffffe, MAX_PAGE_SIZE=65536,
MAX_SQL_LENGTH=1000000000, MAX_TRIGGER_DEPTH=1000,
MAX_VARIABLE_NUMBER=32766, MAX_VDBE_OP=250000000, MAX_WORKER_THREADS=8,
MUTEX_W32, OMIT_AUTOINIT, SYSTEM_MALLOC, TEMP_STORE=1, THREADSAFE=1
- What versions of what packages do you have installed? The output of
pip freeze
is helpful.
pip freeze
coverage==7.8.2
- What code shows the problem?
Simple file: main.py
:
i = 54
print(f"{{this is not an interpolated variable}} but this is: i = {i}")
- What commands should we run to reproduce the problem? Be specific. Include everything, even
git clone
,pip install
, and so on. Explain like we're five!
Create the main.py
file with content above.
Generate coverage:
coverage run main.py
Generate html report:
coverage html
Open the html report in htmlcov/main_py.html
You see that the report is not showing the correct content of the print line.
In plain text:
print(f"{ this is not an interpolated variable} but this is: i = {i}")
Expected behavior
The html rendered line should match exactly the source code which should be:
print(f"{{this is not an interpolated variable}} but this is: i = {i}")
Additional context
n/a