1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
# SPDX-FileCopyrightText: 2022 The meson-python developers
#
# SPDX-License-Identifier: MIT
import pathlib
import subprocess
import sys
import pytest
import mesonpy
from mesonpy._util import chdir
examples_dir = pathlib.Path(__file__).parent.parent / 'docs' / 'examples'
def test_spam(venv, tmp_path):
"""Test that the wheel for the example builds, installs, and imports."""
with chdir(examples_dir / 'spam'):
if sys.version_info < (3, 8):
# The test project requires Python >= 3.8.
with pytest.raises(SystemExit):
mesonpy.build_wheel(tmp_path)
else:
wheel = mesonpy.build_wheel(tmp_path)
subprocess.run(
[venv.executable, '-m', 'pip', 'install', tmp_path / wheel],
check=True)
output = subprocess.run(
[venv.executable, '-c', 'import spam; print(spam.add(1, 2))'],
check=True, stdout=subprocess.PIPE).stdout
assert int(output) == 3
|