Skip to content

Commit

Permalink
Add tests capturing UI expectation for non-interactive argument. Ref #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Nov 27, 2019
1 parent e3aeaaf commit 7cd7256
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_settings.py
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
import os.path
import textwrap
import argparse

from twine import exceptions
from twine import settings
Expand Down Expand Up @@ -81,3 +82,25 @@ def test_client_cert_is_set_and_password_not_if_both_given(entered_password):
username='fakeuser', password='anything', client_cert=client_cert)
assert not settings_obj.password
assert settings_obj.client_cert == client_cert


@pytest.fixture
def parser():
parser = argparse.ArgumentParser()
settings.Settings.register_argparse_arguments(parser)
return parser


class TestArgumentParsing:

def test_non_interactive_flag(self, parser):
args = parser.parse_args(['--non-interactive'])
assert args.non_interactive

def test_non_interactive_environment(self, parser, monkeypatch):
monkeypatch.setenv("TWINE_NON_INTERACTIVE", "1")
args = parser.parse_args([])
assert args.non_interactive
monkeypatch.setenv("TWINE_NON_INTERACTIVE", "0")
args = parser.parse_args([])
assert not args.non_interactive

0 comments on commit 7cd7256

Please sign in to comment.