Skip to content

Commit c15b929

Browse files
committed
Merge branch 'fix-build-error' into dev
2 parents 2a3e1c4 + cc23e4a commit c15b929

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/test_authority.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ def test_lessknown_host_will_return_a_set_of_v1_endpoints(self):
2929
self.assertNotIn('v2.0', a.token_endpoint)
3030

3131
def test_unknown_host_wont_pass_instance_discovery(self):
32-
with self.assertRaisesRegexp(ValueError, "invalid_instance"):
33-
Authority('https://unknown.host/tenant_doesnt_matter_in_this_case')
34-
35-
def test_invalid_host_skipping_validation_meets_connection_error_down_the_road(self):
36-
with self.assertRaises(requests.exceptions.RequestException):
37-
Authority('https://unknown.host/invalid', validate_authority=False)
32+
_assert = getattr(self, "assertRaisesRegex", self.assertRaisesRegexp) # Hack
33+
with _assert(ValueError, "invalid_instance"):
34+
Authority('https://example.com/tenant_doesnt_matter_in_this_case')
35+
36+
def test_invalid_host_skipping_validation_can_be_turned_off(self):
37+
try:
38+
Authority('https://example.com/invalid', validate_authority=False)
39+
except ValueError as e:
40+
if "invalid_instance" in str(e): # Imprecise but good enough
41+
self.fail("validate_authority=False should turn off validation")
42+
except: # Could be requests...RequestException, json...JSONDecodeError, etc.
43+
pass # Those are expected for this unittest case
3844

3945

4046
class TestAuthorityInternalHelperCanonicalize(unittest.TestCase):

0 commit comments

Comments
 (0)