-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn deprecated metadata fields in setup.cfg
- Loading branch information
1 parent
7792fac
commit 6b6736c
Showing
3 changed files
with
84 additions
and
26 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
from setuptools.config.setupcfg import ConfigHandler, Target, read_configuration | ||
from setuptools.dist import Distribution, _Distribution | ||
from setuptools.errors import RemovedConfigError | ||
from setuptools.warnings import SetuptoolsDeprecationWarning | ||
|
||
from ..textwrap import DALS | ||
|
@@ -136,19 +137,20 @@ def test_basic(self, tmpdir): | |
'license': 'BSD 3-Clause License', | ||
} | ||
|
||
with get_dist(tmpdir, meta_initial) as dist: | ||
metadata = dist.metadata | ||
with pytest.warns(SetuptoolsDeprecationWarning, match="Deprecated config"): | ||
with get_dist(tmpdir, meta_initial) as dist: | ||
metadata = dist.metadata | ||
|
||
assert metadata.version == '10.1.1' | ||
assert metadata.description == 'Some description' | ||
assert metadata.long_description_content_type == 'text/something' | ||
assert metadata.long_description == 'readme contents\nline2' | ||
assert metadata.provides == ['package', 'package.sub'] | ||
assert metadata.license == 'BSD 3-Clause License' | ||
assert metadata.name == 'fake_name' | ||
assert metadata.keywords == ['one', 'two'] | ||
assert metadata.download_url == 'http://test.test.com/test/' | ||
assert metadata.maintainer_email == '[email protected]' | ||
assert metadata.version == '10.1.1' | ||
assert metadata.description == 'Some description' | ||
assert metadata.long_description_content_type == 'text/something' | ||
assert metadata.long_description == 'readme contents\nline2' | ||
assert metadata.provides == ['package', 'package.sub'] | ||
assert metadata.license == 'BSD 3-Clause License' | ||
assert metadata.name == 'fake_name' | ||
assert metadata.keywords == ['one', 'two'] | ||
assert metadata.download_url == 'http://test.test.com/test/' | ||
assert metadata.maintainer_email == '[email protected]' | ||
|
||
def test_license_cfg(self, tmpdir): | ||
fake_env( | ||
|
@@ -207,16 +209,17 @@ def test_aliases(self, tmpdir): | |
' Programming Language :: Python :: 3.5\n', | ||
) | ||
|
||
with get_dist(tmpdir) as dist: | ||
metadata = dist.metadata | ||
assert metadata.author_email == '[email protected]' | ||
assert metadata.url == 'http://test.test.com/test/' | ||
assert metadata.description == 'Short summary' | ||
assert metadata.platforms == ['a', 'b'] | ||
assert metadata.classifiers == [ | ||
'Framework :: Django', | ||
'Programming Language :: Python :: 3.5', | ||
] | ||
with pytest.warns(match='Deprecated usage of .url.'): | ||
with get_dist(tmpdir) as dist: | ||
metadata = dist.metadata | ||
assert metadata.author_email == '[email protected]' | ||
assert metadata.url == 'http://test.test.com/test/' | ||
assert metadata.description == 'Short summary' | ||
assert metadata.platforms == ['a', 'b'] | ||
assert metadata.classifiers == [ | ||
'Framework :: Django', | ||
'Programming Language :: Python :: 3.5', | ||
] | ||
|
||
def test_multiline(self, tmpdir): | ||
fake_env( | ||
|
@@ -449,6 +452,39 @@ def test_make_option_lowercase(self, tmpdir): | |
assert metadata.name == 'foo' | ||
assert metadata.description == 'Some description' | ||
|
||
@pytest.mark.parametrize( | ||
("field", "value"), | ||
[ | ||
("provides", "setuptools"), | ||
("obsoletes", "setuptools"), | ||
("url", "www.setuptools.com.br"), | ||
("download_url", "www.setuptools.com.br/42"), | ||
], | ||
) | ||
def test_deprecated(self, tmpdir, field, value): | ||
fake_env( | ||
tmpdir, | ||
f'[metadata]\nname = foo\ndescription = Desc\n{field} = {value}', | ||
) | ||
match = f"Deprecated usage of `{field}`" | ||
with pytest.warns(SetuptoolsDeprecationWarning, match=match): | ||
get_dist(tmpdir).__enter__() | ||
|
||
@pytest.mark.parametrize( | ||
("field", "value"), | ||
[ | ||
("requires", "setuptools"), | ||
], | ||
) | ||
def test_removed(self, tmpdir, field, value): | ||
fake_env( | ||
tmpdir, | ||
f'[metadata]\nname = foo\ndescription = Desc\n{field} = {value}', | ||
) | ||
match = f"Invalid use of `{field}`" | ||
with pytest.raises(RemovedConfigError, match=match): | ||
get_dist(tmpdir).__enter__() | ||
|
||
|
||
class TestOptions: | ||
def test_basic(self, tmpdir): | ||
|
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