Skip to content

Commit 427b1fc

Browse files
committed
TST: use the recommended subprocess API
1 parent f747f77 commit 427b1fc

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

tests/conftest.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ def in_git_repo_context(path=os.path.curdir):
4848
path = os.path.abspath(path)
4949
shutil.rmtree(os.path.join(path, '.git'), ignore_errors=True)
5050
try:
51-
subprocess.check_call(['git', 'init', '-b', 'main', path])
52-
subprocess.check_call(['git', 'config', 'user.email', '[email protected]'], cwd=path)
53-
subprocess.check_call(['git', 'config', 'user.name', 'A U Thor'], cwd=path)
54-
subprocess.check_call(['git', 'add', '*'], cwd=path)
55-
subprocess.check_call(['git', 'commit', '-q', '-m', 'Test'], cwd=path)
51+
subprocess.run(['git', 'init', '-b', 'main', path], check=True)
52+
subprocess.run(['git', 'config', 'user.email', '[email protected]'], cwd=path, check=True)
53+
subprocess.run(['git', 'config', 'user.name', 'A U Thor'], cwd=path, check=True)
54+
subprocess.run(['git', 'add', '*'], cwd=path, check=True)
55+
subprocess.run(['git', 'commit', '-q', '-m', 'Test'], cwd=path, check=True)
5656
yield
5757
finally:
5858
# PermissionError raised on Windows.

tests/docs/examples/test_spam.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def test_build_and_import(venv, tmp_dir_session):
1919
else:
2020
wheel = build_project_wheel(package=examples_dir / 'spam', outdir=tmp_dir_session)
2121

22-
subprocess.check_call([
23-
venv.executable, '-m', 'pip', 'install', wheel
24-
])
25-
output = subprocess.check_output([
26-
venv.executable, '-c', 'import spam; print(spam.add(1, 2))'
27-
])
22+
subprocess.run(
23+
[venv.executable, '-m', 'pip', 'install', wheel],
24+
check=True)
25+
output = subprocess.run(
26+
[venv.executable, '-c', 'import spam; print(spam.add(1, 2))'],
27+
check=True, stdout=subprocess.PIPE).stdout
2828

2929
assert int(output) == 3

tests/test_project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def last_two_meson_args():
6565

6666
# create the build directory ourselves because Project._meson is mocked
6767
builddir = str(tmp_dir_session / 'build')
68-
subprocess.check_call(['meson', 'setup', '.', builddir])
68+
subprocess.run(['meson', 'setup', '.', builddir], check=True)
6969

7070
config_settings = {
7171
'builddir': builddir, # use the build directory we created

tests/test_wheel.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,14 @@ def test_configure_data(wheel_configure_data):
141141

142142
@pytest.mark.skipif(platform.system() != 'Linux', reason='Unsupported on this platform for now')
143143
def test_local_lib(venv, wheel_link_against_local_lib):
144-
subprocess.check_call([
145-
venv.executable, '-m', 'pip', 'install', wheel_link_against_local_lib
146-
])
147-
assert subprocess.check_output([
148-
venv.executable, '-c', 'import example; print(example.example_sum(1, 2))'
149-
]).decode().strip() == '3'
144+
subprocess.run(
145+
[venv.executable, '-m', 'pip', 'install', wheel_link_against_local_lib],
146+
check=True)
147+
output = subprocess.run(
148+
[venv.executable, '-c', 'import example; print(example.example_sum(1, 2))'],
149+
stdout=subprocess.PIPE,
150+
check=True).stdout
151+
assert int(output) == 3
150152

151153

152154
def test_contents_license_file(wheel_license_file):

0 commit comments

Comments
 (0)