Refs #27804 -- Used subTest() in utils_tests/test_encoding.py.

This commit is contained in:
Jon Dufresne 2019-08-26 02:58:06 -07:00 committed by Carlton Gibson
parent 579909a13f
commit 5dac63bb84
1 changed files with 22 additions and 14 deletions

View File

@ -121,10 +121,11 @@ class TestRFC3987IEncodingUtils(unittest.TestCase):
]
for iri, uri in cases:
self.assertEqual(iri_to_uri(iri), uri)
with self.subTest(iri):
self.assertEqual(iri_to_uri(iri), uri)
# Test idempotency.
self.assertEqual(iri_to_uri(iri_to_uri(iri)), uri)
# Test idempotency.
self.assertEqual(iri_to_uri(iri_to_uri(iri)), uri)
def test_uri_to_iri(self):
cases = [
@ -144,10 +145,11 @@ class TestRFC3987IEncodingUtils(unittest.TestCase):
]
for uri, iri in cases:
self.assertEqual(uri_to_iri(uri), iri)
with self.subTest(uri):
self.assertEqual(uri_to_iri(uri), iri)
# Test idempotency.
self.assertEqual(uri_to_iri(uri_to_iri(uri)), iri)
# Test idempotency.
self.assertEqual(uri_to_iri(uri_to_iri(uri)), iri)
def test_complementarity(self):
cases = [
@ -165,13 +167,19 @@ class TestRFC3987IEncodingUtils(unittest.TestCase):
]
for uri, iri in cases:
self.assertEqual(iri_to_uri(uri_to_iri(uri)), uri)
self.assertEqual(uri_to_iri(iri_to_uri(iri)), iri)
with self.subTest(uri):
self.assertEqual(iri_to_uri(uri_to_iri(uri)), uri)
self.assertEqual(uri_to_iri(iri_to_uri(iri)), iri)
def test_escape_uri_path(self):
self.assertEqual(
escape_uri_path('/;some/=awful/?path/:with/@lots/&of/+awful/chars'),
'/%3Bsome/%3Dawful/%3Fpath/:with/@lots/&of/+awful/chars'
)
self.assertEqual(escape_uri_path('/foo#bar'), '/foo%23bar')
self.assertEqual(escape_uri_path('/foo?bar'), '/foo%3Fbar')
cases = [
(
'/;some/=awful/?path/:with/@lots/&of/+awful/chars',
'/%3Bsome/%3Dawful/%3Fpath/:with/@lots/&of/+awful/chars',
),
('/foo#bar', '/foo%23bar'),
('/foo?bar', '/foo%3Fbar'),
]
for uri, expected in cases:
with self.subTest(uri):
self.assertEqual(escape_uri_path(uri), expected)