Skip to content

Commit

Permalink
macaroonbakery/tests: account for python2
Browse files Browse the repository at this point in the history
Exposing the error as-is requires handling of byte notation between
Python 2 and 3 and strings when asserting.

Signed-off-by: Sergio Schvezov <[email protected]>
  • Loading branch information
sergiusens committed Mar 31, 2021
1 parent d139153 commit 388d39e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions macaroonbakery/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import base64
import datetime
import json
import platform
import threading

import macaroonbakery.bakery as bakery
Expand Down Expand Up @@ -555,9 +556,14 @@ def handler(*args):
httpd.server_address[1]),
cookies=client.cookies,
auth=client.auth())
self.assertEquals(str(discharge_error.exception),
'third party refused dischargex: unexpected response: '
"[503] b'bad system'")
if platform.python_version_tuple()[0] == '2':
self.assertEquals(str(discharge_error.exception),
'third party refused dischargex: unexpected response: '
"[503] 'bad system'")
else:
self.assertEquals(str(discharge_error.exception),
'third party refused dischargex: unexpected response: '
"[503] b'bad system'")

finally:
httpd.shutdown()
Expand Down

0 comments on commit 388d39e

Please sign in to comment.