summaryrefslogtreecommitdiff
path: root/setuptools/tests/config
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-04-11 22:18:02 +0100
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-05-16 13:30:13 +0100
commit376da0c45bb7690848120d77c7ffbcec74e68243 (patch)
tree2c71c158039012cde76a8b7de23666406f041485 /setuptools/tests/config
parent4b3d473fca60f14ed62f977d9a8473b51c43aea3 (diff)
downloadpython-setuptools-git-376da0c45bb7690848120d77c7ffbcec74e68243.tar.gz
Add deprecation messages for `namespace_packages`.
The docs in https://setuptools.pypa.io/en/latest/userguide/package_discovery.html and https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ suggest that this field is deprecated.
Diffstat (limited to 'setuptools/tests/config')
-rw-r--r--setuptools/tests/config/test_apply_pyprojecttoml.py17
-rw-r--r--setuptools/tests/config/test_setupcfg.py9
2 files changed, 23 insertions, 3 deletions
diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py
index 4f541697..ca6082e3 100644
--- a/setuptools/tests/config/test_apply_pyprojecttoml.py
+++ b/setuptools/tests/config/test_apply_pyprojecttoml.py
@@ -6,6 +6,7 @@ To run these tests offline, please have a look on ``./downloads/preload.py``
import io
import re
import tarfile
+from inspect import cleandoc
from pathlib import Path
from unittest.mock import Mock
from zipfile import ZipFile
@@ -14,6 +15,7 @@ import pytest
from ini2toml.api import Translator
import setuptools # noqa ensure monkey patch to metadata
+from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
from setuptools.dist import Distribution
from setuptools.config import setupcfg, pyprojecttoml
from setuptools.config import expand
@@ -211,6 +213,21 @@ def test_license_and_license_files(tmp_path):
assert dist.metadata.license == "LicenseRef-Proprietary\n"
+class TestDeprecatedFields:
+ def test_namespace_packages(self, tmp_path):
+ pyproject = tmp_path / "pyproject.toml"
+ config = """
+ [project]
+ name = "myproj"
+ version = "42"
+ [tool.setuptools]
+ namespace-packages = ["myproj.pkg"]
+ """
+ pyproject.write_text(cleandoc(config), encoding="utf-8")
+ with pytest.warns(SetuptoolsDeprecationWarning, match="namespace_packages"):
+ pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
+
+
class TestPresetField:
def pyproject(self, tmp_path, dynamic, extra_content=""):
content = f"[project]\nname = 'proj'\ndynamic = {dynamic!r}\n"
diff --git a/setuptools/tests/config/test_setupcfg.py b/setuptools/tests/config/test_setupcfg.py
index 1f35f836..904b1ef8 100644
--- a/setuptools/tests/config/test_setupcfg.py
+++ b/setuptools/tests/config/test_setupcfg.py
@@ -7,6 +7,7 @@ from unittest.mock import Mock, patch
import pytest
from distutils.errors import DistutilsOptionError, DistutilsFileError
+from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
from setuptools.dist import Distribution, _Distribution
from setuptools.config.setupcfg import ConfigHandler, read_configuration
from ..textwrap import DALS
@@ -409,7 +410,7 @@ class TestMetadata:
'requires = some, requirement\n',
)
- with pytest.deprecated_call():
+ with pytest.warns(SetuptoolsDeprecationWarning, match="requires"):
with get_dist(tmpdir) as dist:
metadata = dist.metadata
@@ -518,7 +519,8 @@ class TestOptions:
'python_requires = >=1.0, !=2.8\n'
'py_modules = module1, module2\n',
)
- with get_dist(tmpdir) as dist:
+ deprec = pytest.warns(SetuptoolsDeprecationWarning, match="namespace_packages")
+ with deprec, get_dist(tmpdir) as dist:
assert dist.zip_safe
assert dist.include_package_data
assert dist.package_dir == {'': 'src', 'b': 'c'}
@@ -572,7 +574,8 @@ class TestOptions:
' http://some.com/here/1\n'
' http://some.com/there/2\n',
)
- with get_dist(tmpdir) as dist:
+ deprec = pytest.warns(SetuptoolsDeprecationWarning, match="namespace_packages")
+ with deprec, get_dist(tmpdir) as dist:
assert dist.package_dir == {'': 'src', 'b': 'c'}
assert dist.packages == ['pack_a', 'pack_b.subpack']
assert dist.namespace_packages == ['pack1', 'pack2']