Use monkeypatch for setting modules in tests
Use monkeypatch for setting modules in tests

Instead of directly setting `sys.modules`. This ensures that they
get removed at the end of the test.

mhils/pytest,abusalimov/pytest,pelme/pytest,mdboom/pytest,mbirtwell/pytest,takluyver/pytest,chillbear/pytest,untitaker/pytest,gabrielcnr/pytest,MengJueM/pytest,Bachmann1234/pytest,ojake/pytest,MichaelAquilina/pytest,rmfitzpatrick/pytest,bukzor/pytest,hpk42/pytest,vodik/pytest,rouge8/pytest,markshao/pytest,codewarrior0/pytest,lukas-bednar/pytest,ericdill/pytest,mdboom/pytest,JonathonSonesen/pytest,Haibo-Wang-ORG/pytest,The-Compiler/pytest,vmalloc/dessert,txomon/pytest,jb098/pytest,omarkohl/pytest,Bjwebb/pytest,hpk42/pytest,abusalimov/pytest,malinoff/pytest,omarkohl/pytest,mhils/pytest,davidszotten/pytest,ghostsquad/pytest,tomviner/pytest,alfredodeza/pytest,ojake/pytest,gabrielcnr/pytest,icemac/pytest,icemac/pytest,MengJueM/pytest,eli-b/pytest,ropez/pytest,inirudebwoy/pytest,Haibo-Wang-ORG/pytest,pytest-dev/pytest,userzimmermann/pytest,RonnyPfannschmidt/pytest,pfctdayelise/pytest,wfxiang08/pytest,takluyver/pytest,pelme/pytest,doordash/pytest,chiller/pytest,untitaker/pytest,skylarjhdownes/pytest,tareqalayan/pytest,Akasurde/pytest,Bachmann1234/pytest,chillbear/pytest,tgoodlet/pytest,oleg-alexandrov/pytest,ropez/pytest,nicoddemus/pytest,ghostsquad/pytest,ericdill/pytest,flub/pytest,hackebrot/pytest,etataurov/pytest,nicoddemus/pytest,ionelmc/pytest,Bjwebb/pytest,codewarrior0/pytest,oleg-alexandrov/pytest,The-Compiler/pytest,vodik/pytest,chiller/pytest,doordash/pytest,mbirtwell/pytest,tomviner/pytest,jaraco/pytest,bukzor/pytest,ionelmc/pytest,userzimmermann/pytest,inirudebwoy/pytest,jb098/pytest,ddboline/pytest,wfxiang08/pytest,lukas-bednar/pytest,JonathonSonesen/pytest,rouge8/pytest