|
|
@@ -0,0 +1,14 @@
|
|
|
+import pytest
|
|
|
+import re
|
|
|
+
|
|
|
+def test_string_rep():
|
|
|
+ cases = ['', ' ', 'a', 'a s !']
|
|
|
+ expected = ['', '%20', 'a', 'a%20s%20!']
|
|
|
+ for c, e in zip(cases, expected):
|
|
|
+ assert string_rep(c) == e
|
|
|
+
|
|
|
+pytest.main()
|
|
|
+
|
|
|
+def string_rep(input):
|
|
|
+ p = re.compile(' ')
|
|
|
+ return p.sub('%20', input)
|