-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: move tests building sdists from test_metadata to test_sdist
- Loading branch information
Showing
2 changed files
with
64 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
# SPDX-License-Identifier: MIT | ||
|
||
import pathlib | ||
import tarfile | ||
import textwrap | ||
|
||
import packaging.version | ||
import pyproject_metadata | ||
|
@@ -34,67 +32,3 @@ def test_package_name_from_pyproject(): | |
def test_package_name_invalid(): | ||
with pytest.raises(pyproject_metadata.ConfigurationError, match='Invalid project name'): | ||
Metadata(name='.test', version=packaging.version.Version('0.0.1')) | ||
|
||
|
||
def test_no_pep621(sdist_library): | ||
with tarfile.open(sdist_library, 'r:gz') as sdist: | ||
sdist_pkg_info = sdist.extractfile('library-1.0.0/PKG-INFO').read().decode() | ||
|
||
assert sdist_pkg_info == textwrap.dedent('''\ | ||
Metadata-Version: 2.1 | ||
Name: library | ||
Version: 1.0.0 | ||
''') | ||
|
||
|
||
def test_pep621(sdist_full_metadata): | ||
with tarfile.open(sdist_full_metadata, 'r:gz') as sdist: | ||
sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read().decode() | ||
|
||
assert sdist_pkg_info == textwrap.dedent('''\ | ||
Metadata-Version: 2.1 | ||
Name: full-metadata | ||
Version: 1.2.3 | ||
Summary: Some package with all of the PEP 621 metadata | ||
Keywords: full metadata | ||
Home-page: https://example.com | ||
Author: Jane Doe | ||
Author-Email: Unknown <[email protected]> | ||
Maintainer-Email: Jane Doe <[email protected]> | ||
License: some license | ||
Classifier: Development Status :: 4 - Beta | ||
Classifier: Programming Language :: Python | ||
Project-URL: Homepage, https://example.com | ||
Project-URL: Documentation, https://readthedocs.org | ||
Project-URL: Repository, https://github.com/mesonbuild/meson-python | ||
Project-URL: Changelog, https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst | ||
Requires-Python: >=3.7 | ||
Requires-Dist: a | ||
Requires-Dist: b>1 | ||
Requires-Dist: c>2; os_name != "nt" | ||
Requires-Dist: d<3; extra == "test" | ||
Requires-Dist: e[all]; extra == "test" | ||
Provides-Extra: test | ||
Description-Content-Type: text/markdown | ||
<!-- | ||
SPDX-FileCopyrightText: 2021 The meson-python developers | ||
SPDX-License-Identifier: MIT | ||
--> | ||
# full-metadata | ||
An example package with all of the PEP 621 metadata! | ||
''') | ||
|
||
|
||
def test_dynamic_version(sdist_dynamic_version): | ||
with tarfile.open(sdist_dynamic_version, 'r:gz') as sdist: | ||
sdist_pkg_info = sdist.extractfile('dynamic_version-1.0.0/PKG-INFO').read().decode() | ||
|
||
assert sdist_pkg_info == textwrap.dedent('''\ | ||
Metadata-Version: 2.1 | ||
Name: dynamic-version | ||
Version: 1.0.0 | ||
''') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,70 @@ | |
from .conftest import in_git_repo_context | ||
|
||
|
||
def test_no_pep621(sdist_library): | ||
with tarfile.open(sdist_library, 'r:gz') as sdist: | ||
sdist_pkg_info = sdist.extractfile('library-1.0.0/PKG-INFO').read().decode() | ||
|
||
assert sdist_pkg_info == textwrap.dedent('''\ | ||
Metadata-Version: 2.1 | ||
Name: library | ||
Version: 1.0.0 | ||
''') | ||
|
||
|
||
def test_pep621(sdist_full_metadata): | ||
with tarfile.open(sdist_full_metadata, 'r:gz') as sdist: | ||
sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read().decode() | ||
|
||
assert sdist_pkg_info == textwrap.dedent('''\ | ||
Metadata-Version: 2.1 | ||
Name: full-metadata | ||
Version: 1.2.3 | ||
Summary: Some package with all of the PEP 621 metadata | ||
Keywords: full metadata | ||
Home-page: https://example.com | ||
Author: Jane Doe | ||
Author-Email: Unknown <[email protected]> | ||
Maintainer-Email: Jane Doe <[email protected]> | ||
License: some license | ||
Classifier: Development Status :: 4 - Beta | ||
Classifier: Programming Language :: Python | ||
Project-URL: Homepage, https://example.com | ||
Project-URL: Documentation, https://readthedocs.org | ||
Project-URL: Repository, https://github.com/mesonbuild/meson-python | ||
Project-URL: Changelog, https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst | ||
Requires-Python: >=3.7 | ||
Requires-Dist: a | ||
Requires-Dist: b>1 | ||
Requires-Dist: c>2; os_name != "nt" | ||
Requires-Dist: d<3; extra == "test" | ||
Requires-Dist: e[all]; extra == "test" | ||
Provides-Extra: test | ||
Description-Content-Type: text/markdown | ||
<!-- | ||
SPDX-FileCopyrightText: 2021 The meson-python developers | ||
SPDX-License-Identifier: MIT | ||
--> | ||
# full-metadata | ||
An example package with all of the PEP 621 metadata! | ||
''') | ||
|
||
|
||
def test_dynamic_version(sdist_dynamic_version): | ||
with tarfile.open(sdist_dynamic_version, 'r:gz') as sdist: | ||
sdist_pkg_info = sdist.extractfile('dynamic_version-1.0.0/PKG-INFO').read().decode() | ||
|
||
assert sdist_pkg_info == textwrap.dedent('''\ | ||
Metadata-Version: 2.1 | ||
Name: dynamic-version | ||
Version: 1.0.0 | ||
''') | ||
|
||
|
||
def test_contents(sdist_library): | ||
with tarfile.open(sdist_library, 'r:gz') as sdist: | ||
names = {member.name for member in sdist.getmembers()} | ||
|