Skip to content

Commit 8f9e362

Browse files
committed
[tests] authproxy.py: tidy up __init__()
1 parent 323d8f6 commit 8f9e362

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

test/functional/test_framework/authproxy.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,9 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect
7171
self._service_name = service_name
7272
self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests
7373
self.__url = urllib.parse.urlparse(service_url)
74-
if self.__url.port is None:
75-
port = 80
76-
else:
77-
port = self.__url.port
78-
(user, passwd) = (self.__url.username, self.__url.password)
79-
try:
80-
user = user.encode('utf8')
81-
except AttributeError:
82-
pass
83-
try:
84-
passwd = passwd.encode('utf8')
85-
except AttributeError:
86-
pass
74+
port = 80 if self.__url.port is None else self.__url.port
75+
user = None if self.__url.username is None else self.__url.username.encode('utf8')
76+
passwd = None if self.__url.password is None else self.__url.password.encode('utf8')
8777
authpair = user + b':' + passwd
8878
self.__auth_header = b'Basic ' + base64.b64encode(authpair)
8979

0 commit comments

Comments
 (0)