Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Tom Myers <tom.stephen.myers@gmail.com>
Rodrigue Cloutier <rodcloutier@gmail.com>
Tyrel Souza <tyrelsouza@gmail.com> (https://tyrelsouza.com)
Adam Talsma <adam@talsma.ca>
Jens Diemer <github@jensdiemer.de> (http://jensdiemer.de/)
28 changes: 28 additions & 0 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import unicode_literals

import os
import textwrap

import pretend
import pytest

Expand Down Expand Up @@ -72,3 +77,26 @@ def test_sign_file_with_identity(monkeypatch):
args = ['gpg', '--detach-sign', '--local-user', 'identity', '-a',
'my_file.tar.gz']
assert replaced_check_call.calls == [pretend.call(args)]


def test_get_config_old_format(tmpdir):
pypirc = os.path.join(str(tmpdir), ".pypirc")

with open(pypirc, "w") as fp:
fp.write(textwrap.dedent("""
[server-login]
username:foo
password:bar
"""))

try:
upload.upload(dists="foo", repository="pypi", sign=None, identity=None,
username=None, password=None, comment=None,
sign_with=None, config_file=pypirc)
except KeyError as err:
assert err.args[0] == (
"Missing 'pypi' section from the configuration file.\n"
"Maybe you have a out-dated '{0}' format?\n"
"more info: "
"https://docs.python.org/distutils/packageindex.html#pypirc\n"
).format(pypirc)
13 changes: 9 additions & 4 deletions twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@ def upload(dists, repository, sign, identity, username, password, comment,
try:
config = get_config(config_file)[repository]
except KeyError:
raise KeyError(
"Missing '{0}' section from the configuration file".format(
repository,
),
msg = (
"Missing '{repo}' section from the configuration file.\n"
"Maybe you have a out-dated '{cfg}' format?\n"
"more info: "
"https://docs.python.org/distutils/packageindex.html#pypirc\n"
).format(
repo=repository,
cfg=config_file
)
raise KeyError(msg)

parsed = urlparse(config["repository"])
if parsed.netloc in ["pypi.python.org", "testpypi.python.org"]:
Expand Down