Add Python 3 support for TestModelsLoaderMixin.

Review Request #9725 — Created March 4, 2018 and submitted — Latest diff uploaded




TestModelsLoaderMixin, which helps unit tests temporarily define
models for test purposes, has been updated to create module in a way
that's compatible with Python 3.4 and higher.

Earlier versions only needed to create a ModuleType instance, but 3.4
and higher has a new module creation and import system, where you create
a ModuleSpec defining aspects of the module and then register a model
based on it. This isn't entirely fleshed out on Python 3.4 (creating a
module requires access to private functions), but on 3.5 and higher
there's a public function for this.

With this change, unit tests can successfully register test models under
Python 3.

Unit tests using this mixin pass (when combined with other upcoming changes)
on Python 2.7, 3.4, 3.5, and 3.6.