Skip to content

Commit 3b60935

Browse files
committed
update _run_tests with better code
1 parent 93044f9 commit 3b60935

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Python/chapter01/1.3 - URLify/miguel_1.3_sol.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ def urlify(s: str, true_length: int) -> str:
3333
class TestUrlifyFunction(unittest.TestCase):
3434
def _run_tests(self, f: Callable[[str, int], str]) -> None:
3535
cases = [
36-
("Mr John Smith ", 13, "Mr%20John%20Smith"),
37-
("Miguel Hernandez", 16, "Miguel%20Hernandez"),
38-
(" Techqueria ", 11, "%20Techqueria"),
39-
("a b c d e f g h", 15, "a%20b%20c%20d%20e%20f%20g%20h"),
40-
("a b c d e f g h ignore this", 15, "a%20b%20c%20d%20e%20f%20g%20h"),
41-
("ihavenospaces", 13, "ihavenospaces"),
42-
("nospacesIgnoreme", 8, "nospaces")
36+
(("Mr John Smith ", 13), "Mr%20John%20Smith"),
37+
(("Miguel Hernandez", 16), "Miguel%20Hernandez"),
38+
((" Techqueria ", 11), "%20Techqueria"),
39+
(("a b c d e f g h", 15), "a%20b%20c%20d%20e%20f%20g%20h"),
40+
(("a b c d e f g h ignore this", 15), "a%20b%20c%20d%20e%20f%20g%20h"),
41+
(("ihavenospaces", 13), "ihavenospaces"),
42+
(("nospacesIgnoreme", 8), "nospaces")
4343
]
44-
for case in cases:
45-
self.assertEqual(f(case[0], case[1]), case[2], msg=case)
44+
for args, expected in cases:
45+
self.assertEqual(f(*args), expected, msg=args)
4646

4747
def test_urlify(self):
4848
self._run_tests(urlify)

0 commit comments

Comments
 (0)