Skip to content

Commit

Permalink
TST: simplify and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi authored and rgommers committed Aug 25, 2023
1 parent 1d4a950 commit b94ddbd
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit b94ddbd

Please sign in to comment.