diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-12-29 12:37:45 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-12-29 12:37:45 +0300 |
commit | a122397b4b5f5ab313f2e3fa28609aaf5cc79ab0 (patch) | |
tree | bb861d7b904d1cf678918b5c9d1ffcec2f4f86bc /sphinx/testing | |
parent | bac090cf40db31ddb74abb573fd3260af3d93734 (diff) | |
parent | 3f7bf48715ed5d6b0cf5d2645ee2886975b97b10 (diff) |
Merge branch '3.x'
Diffstat (limited to 'sphinx/testing')
-rw-r--r-- | sphinx/testing/fixtures.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sphinx/testing/fixtures.py b/sphinx/testing/fixtures.py index 1008ea1b8..906163d56 100644 --- a/sphinx/testing/fixtures.py +++ b/sphinx/testing/fixtures.py @@ -245,3 +245,15 @@ def tempdir(tmpdir: str) -> "util.path": this fixture is for compat with old test implementation. """ return util.path(tmpdir) + + +@pytest.fixture +def rollback_sysmodules(): + """Rollback sys.modules to before testing to unload modules during tests.""" + try: + sysmodules = list(sys.modules) + yield + finally: + for modname in list(sys.modules): + if modname not in sysmodules: + sys.modules.pop(modname) |