Skip to content

Commit 76a2f5f

Browse files
committed
TST: move editable wheel tests to their own file
1 parent 9ac0fa5 commit 76a2f5f

File tree

2 files changed

+55
-48
lines changed

2 files changed

+55
-48
lines changed

tests/test_editable.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: 2021 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import os
6+
import shutil
7+
8+
import mesonpy
9+
10+
11+
def test_editable(
12+
package_imports_itself_during_build,
13+
editable_imports_itself_during_build,
14+
venv,
15+
):
16+
venv.pip('install', os.fspath(editable_imports_itself_during_build))
17+
18+
assert venv.python('-c', 'import plat; print(plat.foo())').strip() == 'bar'
19+
20+
plat = package_imports_itself_during_build / 'plat.c'
21+
plat_text = plat.read_text()
22+
try:
23+
plat.write_text(plat_text.replace('bar', 'something else'))
24+
25+
assert venv.python('-c', 'import plat; print(plat.foo())').strip() == 'something else'
26+
finally:
27+
plat.write_text(plat_text)
28+
29+
30+
def test_editable_broken_non_existent_build_dir(
31+
package_imports_itself_during_build,
32+
editable_imports_itself_during_build,
33+
venv,
34+
tmp_path,
35+
):
36+
# Start from a clean slate, copy the package to temp path
37+
# Ensure there is no .mesonpy directory (could be generated by test_editable)
38+
shutil.rmtree(tmp_path) # copytree requires dest not to exist
39+
shutil.copytree(package_imports_itself_during_build, tmp_path)
40+
mesonpy_dir = os.path.join(package_imports_itself_during_build, '.mesonpy')
41+
if os.path.isdir(mesonpy_dir):
42+
venv.pip('uninstall', '-y', 'imports-itself-during-build')
43+
shutil.rmtree(mesonpy_dir)
44+
45+
venv.pip('install', os.path.join(tmp_path, mesonpy.build_editable(tmp_path)))
46+
47+
# Try corrupting the build dir,
48+
# removing the build dir after an install will trigger it
49+
if os.path.isdir(mesonpy_dir):
50+
venv.pip('uninstall', '-y', 'imports-itself-during-build')
51+
shutil.rmtree(mesonpy_dir)
52+
53+
venv.pip('install', os.path.join(tmp_path, mesonpy.build_editable(tmp_path)))
54+
55+
assert venv.python('-c', 'import plat; print(plat.foo())').strip() == 'bar'

tests/test_wheel.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
import platform
77
import re
8-
import shutil
98
import stat
109
import subprocess
1110
import sys
@@ -240,50 +239,3 @@ def test_top_level_modules(package_module_types):
240239
'namespace',
241240
'native',
242241
}
243-
244-
245-
def test_editable(
246-
package_imports_itself_during_build,
247-
editable_imports_itself_during_build,
248-
venv,
249-
):
250-
venv.pip('install', os.fspath(editable_imports_itself_during_build))
251-
252-
assert venv.python('-c', 'import plat; print(plat.foo())').strip() == 'bar'
253-
254-
plat = package_imports_itself_during_build / 'plat.c'
255-
plat_text = plat.read_text()
256-
try:
257-
plat.write_text(plat_text.replace('bar', 'something else'))
258-
259-
assert venv.python('-c', 'import plat; print(plat.foo())').strip() == 'something else'
260-
finally:
261-
plat.write_text(plat_text)
262-
263-
264-
def test_editable_broken_non_existent_build_dir(
265-
package_imports_itself_during_build,
266-
editable_imports_itself_during_build,
267-
venv,
268-
tmp_path,
269-
):
270-
# Start from a clean slate, copy the package to temp path
271-
# Ensure there is no .mesonpy directory (could be generated by test_editable)
272-
shutil.rmtree(tmp_path) # copytree requires dest not to exist
273-
shutil.copytree(package_imports_itself_during_build, tmp_path)
274-
mesonpy_dir = os.path.join(package_imports_itself_during_build, '.mesonpy')
275-
if os.path.isdir(mesonpy_dir):
276-
venv.pip('uninstall', '-y', 'imports-itself-during-build')
277-
shutil.rmtree(mesonpy_dir)
278-
279-
venv.pip('install', os.path.join(tmp_path, mesonpy.build_editable(tmp_path)))
280-
281-
# Try corrupting the build dir,
282-
# removing the build dir after an install will trigger it
283-
if os.path.isdir(mesonpy_dir):
284-
venv.pip('uninstall', '-y', 'imports-itself-during-build')
285-
shutil.rmtree(mesonpy_dir)
286-
287-
venv.pip('install', os.path.join(tmp_path, mesonpy.build_editable(tmp_path)))
288-
289-
assert venv.python('-c', 'import plat; print(plat.foo())').strip() == 'bar'

0 commit comments

Comments
 (0)