Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "check" command #395

Merged
merged 8 commits into from
Sep 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 1 addition & 12 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
import os.path
import textwrap

try:
import builtins
except ImportError:
import __builtin__ as builtins

import pytest

from twine import utils
Expand Down Expand Up @@ -239,13 +234,7 @@ def keyring_missing(monkeypatch):
"""
Simulate that 'import keyring' raises an ImportError
"""
real_import = builtins.__import__

def my_import(name, *args, **kwargs):
if name == 'keyring':
raise ImportError
return real_import(name, *args, **kwargs)
monkeypatch.setattr(builtins, '__import__', my_import)
monkeypatch.delitem(sys.modules, 'keyring', raising=False)


@pytest.fixture
Expand Down
5 changes: 2 additions & 3 deletions twine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,11 @@ def password_prompt(prompt_text): # Always expects unicode for our own sanity


def get_password_from_keyring(system, username):
try:
import keyring
except ImportError:
if 'keyring' not in sys.modules:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will 'keyring' be in sys.modules before it is imported?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An excellent point...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create an issue 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, I'm already fixing it.

return

try:
import keyring
return keyring.get_password(system, username)
except Exception as exc:
warnings.warn(str(exc))
Expand Down