I think it would be easier to read if you didn't use `\'` here, instead you could use an `r''` or use `""` to avoid the backslash escape for apostrophe.

Also, does this test really demonstrate that `'` is left alone? It appears to be unescaping `%27`, which seems opposite of the comment above.