Commit 7edce734 authored by Dustin Ingram's avatar Dustin Ingram

Tests for deprecation warnings

parent a91c5719
import mock
from distutils import log
import pytest
from setuptools.command.register import register
from setuptools.dist import Distribution
class TestRegisterTest:
def test_warns_deprecation(self):
dist = Distribution()
cmd = register(dist)
cmd.run_command = mock.Mock()
cmd.send_metadata = mock.Mock()
cmd.announce = mock.Mock()
cmd.run()
cmd.announce.assert_called_once_with(
"WARNING: Registering is deprecated, use twine to upload instead "
"(https://pypi.org/p/twine/)",
log.WARN
)
def test_warns_deprecation_when_raising(self):
dist = Distribution()
cmd = register(dist)
cmd.run_command = mock.Mock()
cmd.send_metadata = mock.Mock()
cmd.send_metadata.side_effect = Exception
cmd.announce = mock.Mock()
with pytest.raises(Exception):
cmd.run()
cmd.announce.assert_called_once_with(
"WARNING: Registering is deprecated, use twine to upload instead "
"(https://pypi.org/p/twine/)",
log.WARN
)
import mock
from distutils import log
import pytest
from setuptools.command.upload import upload
from setuptools.dist import Distribution
class TestUploadTest:
def test_warns_deprecation(self):
dist = Distribution()
dist.dist_files = [(mock.Mock(), mock.Mock(), mock.Mock())]
cmd = upload(dist)
cmd.upload_file = mock.Mock()
cmd.announce = mock.Mock()
cmd.run()
cmd.announce.assert_called_once_with(
"WARNING: Uploading via this command is deprecated, use twine to "
"upload instead (https://pypi.org/p/twine/)",
log.WARN
)
def test_warns_deprecation_when_raising(self):
dist = Distribution()
dist.dist_files = [(mock.Mock(), mock.Mock(), mock.Mock())]
cmd = upload(dist)
cmd.upload_file = mock.Mock()
cmd.upload_file.side_effect = Exception
cmd.announce = mock.Mock()
with pytest.raises(Exception):
cmd.run()
cmd.announce.assert_called_once_with(
"WARNING: Uploading via this command is deprecated, use twine to "
"upload instead (https://pypi.org/p/twine/)",
log.WARN
)
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