Add Python 3 support for TestModelsLoaderMixin.

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

Christian Hammond

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.

  • 0
  • 0
  • 0
  • 1
  • 1
Description From Last Updated
Christian Hammond
David Trowbridge
  2. djblets/testing/ (Diff revision 1)

    This looks like it should fit on one line.

    1. Just helps a bit with the readability. This isn't any different than what we typically do when using keyword arguments.

    2. Either way. I usually don't start wrapping one-per-line until it gets bigger than this but that's just a preference.

Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (fe59e0b)