Skip to content

Commit 1d4a950

Browse files
dnicolodirgommers
authored andcommitted
TST: reorder and uniform skip markers
Group similar tests together and use similar constructs to skip tests on platforms not supporting the tested features. This made it evident that we are skipping a valid test on macOS. Fix that.
1 parent 83e2bc0 commit 1d4a950

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

tests/test_wheel.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,6 @@ def test_scipy_like(wheel_scipy_like):
8585
assert name.group('plat') == PLATFORM
8686

8787

88-
@pytest.mark.skipif(platform.system() != 'Linux', reason='Needs library vendoring, only implemented in POSIX')
89-
def test_contents(package_library, wheel_library):
90-
artifact = wheel.wheelfile.WheelFile(wheel_library)
91-
92-
for name, regex in zip(sorted(wheel_contents(artifact)), [
93-
re.escape('.library.mesonpy.libs/libexample.so'),
94-
re.escape('library-1.0.0.data/headers/examplelib.h'),
95-
re.escape('library-1.0.0.data/scripts/example'),
96-
re.escape('library-1.0.0.dist-info/METADATA'),
97-
re.escape('library-1.0.0.dist-info/RECORD'),
98-
re.escape('library-1.0.0.dist-info/WHEEL'),
99-
re.escape('library.libs/libexample.so'),
100-
]):
101-
assert re.match(regex, name), f'{name!r} does not match {regex!r}'
102-
103-
10488
def test_purelib_and_platlib(wheel_purelib_and_platlib):
10589
artifact = wheel.wheelfile.WheelFile(wheel_purelib_and_platlib)
10690

@@ -144,47 +128,35 @@ def test_configure_data(wheel_configure_data):
144128
}
145129

146130

147-
@pytest.mark.skipif(platform.system() not in ['Linux', 'Darwin'], reason='Unsupported on this platform for now')
148-
def test_local_lib(venv, wheel_link_against_local_lib):
149-
venv.pip('install', wheel_link_against_local_lib)
150-
output = venv.python('-c', 'import example; print(example.example_sum(1, 2))')
151-
assert int(output) == 3
152-
153-
154131
def test_contents_license_file(wheel_license_file):
155132
artifact = wheel.wheelfile.WheelFile(wheel_license_file)
156133
assert artifact.read('license_file-1.0.0.dist-info/LICENSE.custom').rstrip() == b'Hello!'
157134

158135

159-
@pytest.mark.skipif(sys.platform in {'win32', 'cygwin'}, reason='Platform does not support executable bit')
160-
def test_executable_bit(wheel_executable_bit):
161-
artifact = wheel.wheelfile.WheelFile(wheel_executable_bit)
162-
163-
executable_files = {
164-
'executable_bit-1.0.0.data/purelib/executable_module.py',
165-
'executable_bit-1.0.0.data/scripts/example',
166-
'executable_bit-1.0.0.data/scripts/example-script',
167-
}
168-
for info in artifact.infolist():
169-
mode = (info.external_attr >> 16) & 0o777
170-
assert bool(mode & stat.S_IXUSR) == (info.filename in executable_files)
171-
136+
@pytest.mark.skipif(platform.system() not in {'Linux', 'Darwin'}, reason='Not supported on this platform')
137+
def test_contents(package_library, wheel_library):
138+
artifact = wheel.wheelfile.WheelFile(wheel_library)
172139

173-
def test_detect_wheel_tag_module(wheel_purelib_and_platlib):
174-
name = wheel.wheelfile.WheelFile(wheel_purelib_and_platlib).parsed_filename
175-
assert name.group('pyver') == INTERPRETER
176-
assert name.group('abi') == ABI
177-
assert name.group('plat') == PLATFORM
140+
for name, regex in zip(sorted(wheel_contents(artifact)), [
141+
re.escape('.library.mesonpy.libs/libexample.so'),
142+
re.escape('library-1.0.0.data/headers/examplelib.h'),
143+
re.escape('library-1.0.0.data/scripts/example'),
144+
re.escape('library-1.0.0.dist-info/METADATA'),
145+
re.escape('library-1.0.0.dist-info/RECORD'),
146+
re.escape('library-1.0.0.dist-info/WHEEL'),
147+
re.escape('library.libs/libexample.so'),
148+
]):
149+
assert re.match(regex, name), f'{name!r} does not match {regex!r}'
178150

179151

180-
def test_detect_wheel_tag_script(wheel_executable):
181-
name = wheel.wheelfile.WheelFile(wheel_executable).parsed_filename
182-
assert name.group('pyver') == 'py3'
183-
assert name.group('abi') == 'none'
184-
assert name.group('plat') == PLATFORM
152+
@pytest.mark.skipif(platform.system() not in {'Linux', 'Darwin'}, reason='Not supported on this platform')
153+
def test_local_lib(venv, wheel_link_against_local_lib):
154+
venv.pip('install', wheel_link_against_local_lib)
155+
output = venv.python('-c', 'import example; print(example.example_sum(1, 2))')
156+
assert int(output) == 3
185157

186158

187-
@pytest.mark.skipif(platform.system() not in ['Linux', 'Darwin'], reason='Unsupported on this platform for now')
159+
@pytest.mark.skipif(platform.system() not in {'Linux', 'Darwin'}, reason='Not supported on this platform')
188160
def test_rpath(wheel_link_against_local_lib, tmp_path):
189161
artifact = wheel.wheelfile.WheelFile(wheel_link_against_local_lib)
190162
artifact.extractall(tmp_path)
@@ -197,7 +169,7 @@ def test_rpath(wheel_link_against_local_lib, tmp_path):
197169
assert '@loader_path/.link_against_local_lib.mesonpy.libs' in dylib.rpath
198170

199171

200-
@pytest.mark.skipif(platform.system() not in ['Linux', 'Darwin'], reason='Unsupported on this platform for now')
172+
@pytest.mark.skipif(platform.system() not in {'Linux', 'Darwin'}, reason='Not supported on this platform')
201173
def test_uneeded_rpath(wheel_purelib_and_platlib, tmp_path):
202174
artifact = wheel.wheelfile.WheelFile(wheel_purelib_and_platlib)
203175
artifact.extractall(tmp_path)
@@ -213,6 +185,34 @@ def test_uneeded_rpath(wheel_purelib_and_platlib, tmp_path):
213185
assert 'mesonpy.libs' not in rpath
214186

215187

188+
@pytest.mark.skipif(platform.system() not in {'Linux', 'Darwin'}, reason='Not supported on this platform')
189+
def test_executable_bit(wheel_executable_bit):
190+
artifact = wheel.wheelfile.WheelFile(wheel_executable_bit)
191+
192+
executable_files = {
193+
'executable_bit-1.0.0.data/purelib/executable_module.py',
194+
'executable_bit-1.0.0.data/scripts/example',
195+
'executable_bit-1.0.0.data/scripts/example-script',
196+
}
197+
for info in artifact.infolist():
198+
mode = (info.external_attr >> 16) & 0o777
199+
assert bool(mode & stat.S_IXUSR) == (info.filename in executable_files)
200+
201+
202+
def test_detect_wheel_tag_module(wheel_purelib_and_platlib):
203+
name = wheel.wheelfile.WheelFile(wheel_purelib_and_platlib).parsed_filename
204+
assert name.group('pyver') == INTERPRETER
205+
assert name.group('abi') == ABI
206+
assert name.group('plat') == PLATFORM
207+
208+
209+
def test_detect_wheel_tag_script(wheel_executable):
210+
name = wheel.wheelfile.WheelFile(wheel_executable).parsed_filename
211+
assert name.group('pyver') == 'py3'
212+
assert name.group('abi') == 'none'
213+
assert name.group('plat') == PLATFORM
214+
215+
216216
def test_entrypoints(wheel_full_metadata):
217217
artifact = wheel.wheelfile.WheelFile(wheel_full_metadata)
218218

0 commit comments

Comments
 (0)