From b94ddbd86acc18822437e9d3e95dadb4930d60ad Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Wed, 23 Aug 2023 18:00:59 +0200 Subject: [PATCH] TST: simplify and fix test --- tests/test_wheel.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/test_wheel.py b/tests/test_wheel.py index 296bbc379..9991e9500 100644 --- a/tests/test_wheel.py +++ b/tests/test_wheel.py @@ -34,6 +34,13 @@ if sys.platform in {'win32', 'cygwin'}: EXT_IMP_SUFFIX = re.sub(r'.(pyd|dll)$', '.lib' if shutil.which('cl.exe') else '.dll.a', EXT_SUFFIX) +LIB_SUFFIX = { + 'cygwin': '.dll', + 'darwin': '.dylib', + 'linux': '.so', + 'win32': '.dll', +}[sys.platform] + # Test against the wheel tag generated by packaging module. tag = next(packaging.tags.sys_tags()) ABI = tag.abi @@ -137,16 +144,14 @@ def test_contents_license_file(wheel_license_file): def test_contents(package_library, wheel_library): artifact = wheel.wheelfile.WheelFile(wheel_library) - for name, regex in zip(sorted(wheel_contents(artifact)), [ - re.escape('.library.mesonpy.libs/libexample.so'), - re.escape('library-1.0.0.data/headers/examplelib.h'), - re.escape('library-1.0.0.data/scripts/example'), - re.escape('library-1.0.0.dist-info/METADATA'), - re.escape('library-1.0.0.dist-info/RECORD'), - re.escape('library-1.0.0.dist-info/WHEEL'), - re.escape('library.libs/libexample.so'), - ]): - assert re.match(regex, name), f'{name!r} does not match {regex!r}' + assert wheel_contents(artifact) == { + f'.library.mesonpy.libs/libexample{LIB_SUFFIX}', + 'library-1.0.0.data/headers/examplelib.h', + 'library-1.0.0.data/scripts/example', + 'library-1.0.0.dist-info/METADATA', + 'library-1.0.0.dist-info/RECORD', + 'library-1.0.0.dist-info/WHEEL', + } @pytest.mark.skipif(platform.system() not in {'Linux', 'Darwin'}, reason='Not supported on this platform')