Python warnings.warn() in a loop prints only once per source line: three calls, one line of output
The default warning action shows a given warning only once per location (message, category, module and line), recording it in the module's __warningregistry__. Calling a function that does warnings.warn('x') three times prints UserWarning: x a single time, so logs make a repeated problem look like a one-off and occurrence counts are wrong. Inside warnings.catch_warnings(record=True) the same filter applies, so tests that trigger a warning several times record only one unless they set warnings.simplefilter('always') inside the block. Fix: use warnings.simplefilter('always') (or -W always) when you need every occurrence, and in tests always call simplefilter('always') inside catch_warnings or use pytest.warns. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.