Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_setup_logging(verbose, log_level):
"""Set log level based on verbose field."""
settings.Settings(verbose=verbose)
logger = logging.getLogger("twine")
assert logger.level == log_level
def test_password_is_required_if_no_client_cert(client_cert, entered_password):
"""Set password when client_cert is not provided."""
settings_obj = settings.Settings(username="fakeuser", client_cert=client_cert)
assert settings_obj.password == "entered pw"
def test_settings_takes_no_positional_arguments():
"""Raise an exception when Settings is initialized without keyword arguments."""
with pytest.raises(TypeError):
settings.Settings("a", "b", "c")
def test_client_cert_is_set_and_password_not_if_both_given(entered_password):
"""Set password and client_cert when both are provided."""
client_cert = "/random/path"
settings_obj = settings.Settings(
username="fakeuser", password="anything", client_cert=client_cert
)
assert not settings_obj.password
assert settings_obj.client_cert == client_cert
def test_password_not_required_if_client_cert(entered_password):
"""Don't set password when only client_cert is provided."""
test_client_cert = "/random/path"
settings_obj = settings.Settings(username="fakeuser", client_cert=test_client_cert)
assert not settings_obj.password
assert settings_obj.client_cert == test_client_cert
def test_identity_requires_sign():
"""Raise an exception when user provides identity but doesn't require sigining."""
with pytest.raises(exceptions.InvalidSigningConfiguration):
settings.Settings(sign=False, identity="fakeid")