test: Change syntax for greater compatibility with Python 3.

We still have some way to go, but it is getting shorter.