Refactor test_escape_single_quote_in_raw_query to support Python 2.6.

As spotted by [@hynecker](https://github.com/hynekcer), in  f02892bfde843ca389f4992fa9179ee614f032b4 I broke compatibility with Python 2.6 while running the test suite.  Rewrote the offending line.