Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions tests/packages/missing-dynamic-version/meson.build

This file was deleted.

11 changes: 0 additions & 11 deletions tests/packages/missing-dynamic-version/pyproject.toml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/packages/missing-meson-version/meson.build

This file was deleted.

7 changes: 0 additions & 7 deletions tests/packages/missing-meson-version/pyproject.toml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/packages/unsupported-python-version/meson.build

This file was deleted.

12 changes: 0 additions & 12 deletions tests/packages/unsupported-python-version/pyproject.toml

This file was deleted.

50 changes: 41 additions & 9 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,54 @@
from .conftest import MESON_VERSION, in_git_repo_context, metadata, package_dir


def test_unsupported_python_version(package_unsupported_python_version):
def test_unsupported_python_version(tmp_path):
tmp_path.joinpath('pyproject.toml').write_text(textwrap.dedent('''
[project]
name = 'test'
version = '1.0.0'
requires-python = '==1.0.0'
'''), encoding='utf8')

tmp_path.joinpath('meson.build').write_text(textwrap.dedent('''
project('test', version: '1.0.0')
'''), encoding='utf8')

with pytest.raises(mesonpy.MesonBuilderError, match='The package requires Python version ==1.0.0'):
with mesonpy._project():
pass
mesonpy.Project(tmp_path, tmp_path / 'build')


def test_missing_meson_version(tmp_path):
tmp_path.joinpath('pyproject.toml').write_text(textwrap.dedent('''
[build-system]
build-backend = 'mesonpy'
requires = ['meson-python']
'''), encoding='utf8')

tmp_path.joinpath('meson.build').write_text(textwrap.dedent('''
project('test')
'''), encoding='utf8')

def test_missing_meson_version(package_missing_meson_version):
with pytest.raises(pyproject_metadata.ConfigurationError, match='Section "project" missing in pyproject.toml'):
with mesonpy._project():
pass
mesonpy.Project(tmp_path, tmp_path / 'build')


def test_missing_dynamic_version(tmp_path):
tmp_path.joinpath('pyproject.toml').write_text(textwrap.dedent('''
[build-system]
build-backend = 'mesonpy'
requires = ['meson-python']

[project]
name = 'test'
dynamic = ['version']
'''), encoding='utf8')

tmp_path.joinpath('meson.build').write_text(textwrap.dedent('''
project('test')
'''), encoding='utf8')

def test_missing_dynamic_version(package_missing_dynamic_version):
with pytest.raises(pyproject_metadata.ConfigurationError, match='Field "version" declared as dynamic but'):
with mesonpy._project():
pass
mesonpy.Project(tmp_path, tmp_path / 'build')


@pytest.mark.skipif(MESON_VERSION < (1, 6, 0), reason='meson too old')
Expand Down
Loading