]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
use importlib.machinery to load modules instead of imp under Python 3.3 and greater
authorMatt Chisholm <matt@theory.org>
Mon, 14 Apr 2014 17:54:01 +0000 (13:54 -0400)
committerMatt Chisholm <matt@theory.org>
Mon, 14 Apr 2014 17:58:39 +0000 (13:58 -0400)
part of #2830

lib/sqlalchemy/testing/plugin/noseplugin.py
sqla_nose.py

index 18a1178a603eb8e7bd0e07be8c6e641a7629f7de..bd38745c0f7dd9cb75863411d9fee4a27167a83f 100644 (file)
@@ -12,15 +12,20 @@ way (e.g. as a package-less import).
 """
 
 import os
+import sys
 
 from nose.plugins import Plugin
 fixtures = None
 
 # no package imports yet!  this prevents us from tripping coverage
 # too soon.
-import imp
 path = os.path.join(os.path.dirname(__file__), "plugin_base.py")
-plugin_base = imp.load_source("plugin_base", path)
+if sys.version_info >= (3,3):
+    from importlib import machinery
+    plugin_base = machinery.SourceFileLoader("plugin_base", path).load_module()
+else:
+    import imp
+    plugin_base = imp.load_source("plugin_base", path)
 
 
 class NoseSQLAlchemy(Plugin):
index a01e00152cb30accd153f0a0f98b3a48e54ea1f4..281b729a5ffde3638a5e85d6f84ab4b6f5208fbe 100755 (executable)
@@ -7,7 +7,6 @@ installs SQLAlchemy's testing plugin into the local environment.
 
 """
 import sys
-import imp
 import nose
 import warnings
 
@@ -19,7 +18,12 @@ for pth in ['./lib']:
 # installing without importing SQLAlchemy, so that coverage includes
 # SQLAlchemy itself.
 path = "lib/sqlalchemy/testing/plugin/noseplugin.py"
-noseplugin = imp.load_source("noseplugin", path)
+if sys.version_info >= (3,3):
+    from importlib import machinery
+    noseplugin = machinery.SourceFileLoader("noseplugin", path).load_module()
+else:
+    import imp
+    noseplugin = imp.load_source("noseplugin", path)
 
 
 nose.main(addplugins=[noseplugin.NoseSQLAlchemy()])