test: Make print calls compatible with Python 3

Turn print calls into print() function calls and avoid using comma-separated
arguments, so that they work and look the same with both Python 2 and 3.
test: Make exception catching compatible with Python 3

Use "except Type as var" syntax to work with both Python >= 2.6 and Python 3.
test: Replace obsolete has_key() with "in" to also work with Python 3
test: Move from static gobject bindings to GI

Use GLib gobject-introspection bindings so that we can also use the scripts
with Python 3.
test: Convert to Python 3

Change raw_input() to input() and unicode to str. This is *not* compatible with
Python 2.