Commit 3a9dc2b0 authored by robinjhuang's avatar robinjhuang Committed by Paul Ganssle

Add unit tests for setuptools deprecation warnings

These are tests to ensure that the specified deprecation warnings are
raised when the functions are called.
Co-authored-by: default avatarJunhan Huang <robin.j.huang@gmail.com>
Co-authored-by: default avatarMarton Pono <marci93@gmail.com>
parent 9d63059f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import io import io
from setuptools.dist import DistDeprecationWarning, _get_unpatched
from setuptools import Distribution from setuptools import Distribution
from setuptools.extern.six.moves.urllib.request import pathname2url from setuptools.extern.six.moves.urllib.request import pathname2url
from setuptools.extern.six.moves.urllib_parse import urljoin from setuptools.extern.six.moves.urllib_parse import urljoin
...@@ -56,6 +56,9 @@ def test_dist_fetch_build_egg(tmpdir): ...@@ -56,6 +56,9 @@ def test_dist_fetch_build_egg(tmpdir):
assert [dist.key for dist in resolved_dists if dist] == reqs assert [dist.key for dist in resolved_dists if dist] == reqs
def test_dist__get_unpatched_deprecated():
pytest.warns(DistDeprecationWarning, _get_unpatched, [""])
def __maintainer_test_cases(): def __maintainer_test_cases():
attrs = {"name": "package", attrs = {"name": "package",
"version": "1.0", "version": "1.0",
......
...@@ -15,7 +15,7 @@ import distutils.errors ...@@ -15,7 +15,7 @@ import distutils.errors
import io import io
import zipfile import zipfile
import mock import mock
from setuptools.command.easy_install import EasyInstallDeprecationWarning, ScriptWriter, WindowsScriptWriter
import time import time
from setuptools.extern import six from setuptools.extern import six
from setuptools.extern.six.moves import urllib from setuptools.extern.six.moves import urllib
...@@ -288,6 +288,22 @@ class TestEasyInstallTest: ...@@ -288,6 +288,22 @@ class TestEasyInstallTest:
assert (target / 'mypkg_script').exists() assert (target / 'mypkg_script').exists()
def test_dist_get_script_args_deprecated(self):
with pytest.warns(EasyInstallDeprecationWarning):
ScriptWriter.get_script_args(None, None)
def test_dist_get_script_header_deprecated(self):
with pytest.warns(EasyInstallDeprecationWarning):
ScriptWriter.get_script_header("")
def test_dist_get_writer_deprecated(self):
with pytest.warns(EasyInstallDeprecationWarning):
ScriptWriter.get_writer(None)
def test_dist_WindowsScriptWriter_get_writer_deprecated(self):
with pytest.warns(EasyInstallDeprecationWarning):
WindowsScriptWriter.get_writer()
@pytest.mark.filterwarnings('ignore:Unbuilt egg') @pytest.mark.filterwarnings('ignore:Unbuilt egg')
class TestPTHFileWriter: class TestPTHFileWriter:
def test_add_from_cwd_site_sets_dirty(self): def test_add_from_cwd_site_sets_dirty(self):
......
...@@ -7,7 +7,7 @@ import re ...@@ -7,7 +7,7 @@ import re
import stat import stat
import time import time
from setuptools.command.egg_info import egg_info, manifest_maker from setuptools.command.egg_info import egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision
from setuptools.dist import Distribution from setuptools.dist import Distribution
from setuptools.extern.six.moves import map from setuptools.extern.six.moves import map
...@@ -603,3 +603,6 @@ class TestEggInfo: ...@@ -603,3 +603,6 @@ class TestEggInfo:
with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file: with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file:
pkg_info_lines = pkginfo_file.read().split('\n') pkg_info_lines = pkginfo_file.read().split('\n')
assert 'Version: 0.0.0.dev0' in pkg_info_lines assert 'Version: 0.0.0.dev0' in pkg_info_lines
def test_get_pkg_info_revision_deprecated(self):
pytest.warns(EggInfoDeprecationWarning, get_pkg_info_revision)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment