Skip to content

Commit 39f2ef2

Browse files
dnicolodirgommers
authored andcommitted
TST: fix test leaving behind an undesirable environment variable
1 parent a6eb22a commit 39f2ef2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/test_wheel.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5+
import os
56
import platform
67
import re
78
import shutil
@@ -246,10 +247,15 @@ def test_purelib_platlib_split(package_purelib_platlib_split, tmp_path):
246247
@pytest.mark.skipif(platform.system() != 'Darwin', reason='macOS specific test')
247248
@pytest.mark.parametrize(('arch'), ['x86_64', 'arm64'])
248249
def test_archflags_envvar(package_purelib_and_platlib, monkeypatch, tmp_path, arch):
249-
monkeypatch.setenv('ARCHFLAGS', f'-arch {arch}')
250-
filename = mesonpy.build_wheel(tmp_path)
251-
name = wheel.wheelfile.WheelFile(tmp_path / filename).parsed_filename
252-
assert name.group('plat').endswith(arch)
250+
try:
251+
monkeypatch.setenv('ARCHFLAGS', f'-arch {arch}')
252+
filename = mesonpy.build_wheel(tmp_path)
253+
name = wheel.wheelfile.WheelFile(tmp_path / filename).parsed_filename
254+
assert name.group('plat').endswith(arch)
255+
finally:
256+
# revert environment variable setting done by the in-process build
257+
if '_PYTHON_HOST_PLATFORM' in os.environ:
258+
del os.environ['_PYTHON_HOST_PLATFORM']
253259

254260

255261
def test_subprojects(package_subproject, tmp_path):

0 commit comments

Comments
 (0)