Backport PR #4972: Work around problem in doctest discovery in Python 3.4 with PyQt

Closes gh-4892