diff --git a/coreapi/transports/http.py b/coreapi/transports/http.py index a548024..4c741b5 100644 --- a/coreapi/transports/http.py +++ b/coreapi/transports/http.py @@ -345,16 +345,22 @@ def __init__(self, credentials=None, headers=None, auth=None, session=None, requ session.cookies.set_policy(BlockAll()) if credentials is not None: - warnings.warn( - "The 'credentials' argument is now deprecated in favor of 'auth'.", - DeprecationWarning - ) - auth = DomainCredentials(credentials) + if auth is not None: + warnings.warn( + "Ignoring 'credentials' argument in favor of 'auth'.", + stacklevel=2 + ) + else: + warnings.warn( + "The 'credentials' argument is now deprecated in favor of 'auth'.", + DeprecationWarning, stacklevel=2 + ) + session.auth = DomainCredentials(credentials) if request_callback is not None or response_callback is not None: warnings.warn( "The 'request_callback' and 'response_callback' arguments are now deprecated. " "Use a custom 'session' instance instead.", - DeprecationWarning + DeprecationWarning, stacklevel=2 ) session.mount('https://', CallbackAdapter(request_callback, response_callback)) session.mount('http://', CallbackAdapter(request_callback, response_callback))