Using mutable default arguments (lists, dicts) in python is usually a very bad idea.
https://florimond.dev/blog/articles/2018/08/python-mutable-defaults-are-the-source-of-all-evil/
This fixes a few instances in the main CI test directory, and adds a linter to detect new cases.
I found some more cases in contrib/buildbot and contrib/teamcity, that I would like to address in a separate diff because they are a bit trickier to investigate and harder to debug.
Backport of Core PR16726