From 5fa1e54969497de5c191298bf45f0fb8131a8a6f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Aug 2022 10:00:15 -0400 Subject: [PATCH] Suppress path mangling when running tests. Ref pypa/distutils#169. --- conftest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/conftest.py b/conftest.py index 14afaea1..d07febe1 100644 --- a/conftest.py +++ b/conftest.py @@ -135,3 +135,25 @@ def cleanup_testfn(): os.remove(path) elif os.path.isdir(path): shutil.rmtree(path) + + +# from pytest-dev/pytest#363 +@pytest.fixture(scope="session") +def monkeysession(request): + from _pytest.monkeypatch import MonkeyPatch + + mpatch = MonkeyPatch() + yield mpatch + mpatch.undo() + + +@pytest.fixture(autouse=True, scope="session") +def suppress_path_mangle(monkeysession): + """ + Disable the path mangling in CCompiler. Workaround for #169. + """ + from distutils import ccompiler + + monkeysession.setattr( + ccompiler.CCompiler, '_mangle_base', staticmethod(lambda x: x) + )