Skip to content

Commit

Permalink
Fix #13, Add twine for uploads to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
relekang committed Aug 2, 2015
1 parent ecd9e9a commit eec2561
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -5,4 +5,5 @@ click==4.1
gitpython==1.0.1
invoke==0.10.1
semver==2.2.0
twine==1.5.0
wheel
6 changes: 5 additions & 1 deletion semantic_release/helpers.py
Expand Up @@ -2,6 +2,7 @@

import semver
from invoke import run
from twine.commands import upload as twine_upload

from semantic_release.settings import load_config

Expand All @@ -11,7 +12,10 @@ def get_current_version():


def upload_to_pypi(dists='bdist_wheel'):
return run('python setup.py {} upload && rm -rf build dist'.format(dists))
run('python setup.py {}'.format(dists))
twine_upload.upload(dists=['dist/*'], repository='pypi', sign=False, identity=None,
username=None, password=None, comment=None, sign_with='gpg')
run('rm -rf build dist')


def get_new_version(current_version, level_bump):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -44,6 +44,7 @@ def _read_long_description():
'gitpython==1.0.1',
'invoke==0.10.1',
'semver==2.2.0',
'twine==1.5.0',
'wheel'
],
entry_points='''
Expand Down
30 changes: 23 additions & 7 deletions tests/test_helpers.py
Expand Up @@ -5,13 +5,11 @@


class GetCurrentVersionTests(TestCase):

def test_should_return_correct_version(self):
self.assertEqual(get_current_version(), semantic_release.__version__)


class GetNewVersionTests(TestCase):

def test_major_bump(self):
self.assertEqual(get_new_version('0.0.0', 'major'), '1.0.0')
self.assertEqual(get_new_version('0.1.0', 'major'), '1.0.0')
Expand All @@ -34,13 +32,31 @@ def test_None_bump(self):


class PypiTests(TestCase):

@mock.patch('semantic_release.helpers.run')
def test_upload_without_arguments(self, mock_run):
@mock.patch('twine.commands.upload.upload')
def test_upload_without_arguments(self, mock_upload, mock_run):
upload_to_pypi()
mock_run.assert_called_once_with('python setup.py bdist_wheel upload && rm -rf build dist')
self.assertEqual(
mock_run.call_args_list,
[mock.call('python setup.py bdist_wheel'), mock.call('rm -rf build dist')]
)
mock_upload.assert_called_once_with(
dists=['dist/*'],
repository='pypi',
sign=False,
identity=None,
username=None,
password=None,
comment=None,
sign_with='gpg'
)

@mock.patch('semantic_release.helpers.run')
def test_upload_with_arguments(self, mock_run):
@mock.patch('twine.commands.upload.upload')
def test_upload_with_arguments(self, mock_upload, mock_run):
upload_to_pypi(dists='sdist')
mock_run.assert_called_once_with('python setup.py sdist upload && rm -rf build dist')
self.assertEqual(
mock_run.call_args_list,
[mock.call('python setup.py sdist'), mock.call('rm -rf build dist')]
)
self.assertTrue(mock_upload.called)

0 comments on commit eec2561

Please sign in to comment.