Add Python 3 support for TestModelsLoaderMixin.
Review Request #9725 — Created March 4, 2018 and submitted
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
ModuleTypeinstance, but 3.4
and higher has a new module creation and import system, where you create
ModuleSpecdefining 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
Unit tests using this mixin pass (when combined with other upcoming changes)
on Python 2.7, 3.4, 3.5, and 3.6.