TIL: Mutation Testing.
Mutation testing is used to design new software tests and evaluate the quality of existing software tests. Mutation testing involves modifying a program in small ways. Each mutated version is called a mutant and tests detect and reject mutants by causing the behaviour of the original version to differ from the mutant.
With that defined, yes it can be done with macros. You have to create an macro that traverse your program AST¹ and change it.
I would use patchFile².
For patching test³ template from unittest to change tested function AST.
Or to change imported files directly with regexp mutated version.