Unblock migrate (py26 and py3* testing issues)

There are two changes which have to go together to pass the gate
tests:

1. Update pbr and mock requirements from global-requirements

mock 1.2 supports py26 again so make that the minimum version. The
same change is being made in g-r with:

Ic6b9e18eaec9c81bbbbc57129e024904be928e09

Sync up with latest pbr in global-requirements while we're at it.

Closes-Bug: #1474925

2. Fix the importpath module to work with python >= 3.3 where the
__import__ built-in is raising an ImportError on a temporary file
that is added to the system path.

Closes-Bug: #1475339

Change-Id: Ie98938ba75f3983094dd540b7d26a7ec46be4f6e
This commit is contained in:
Matt Riedemann 2015-07-15 09:02:50 -07:00
parent 050b646e86
commit 8252703f56
4 changed files with 33 additions and 13 deletions

View File

@ -1,18 +1,30 @@
import os
import sys
from six.moves import reload_module as reload
PY33 = sys.version_info >= (3, 3)
if PY33:
from importlib import machinery
else:
from six.moves import reload_module as reload
def import_path(fullpath):
""" Import a file with full path specification. Allows one to
import from anywhere, something __import__ does not do.
"""
# http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html
path, filename = os.path.split(fullpath)
filename, ext = os.path.splitext(filename)
sys.path.append(path)
module = __import__(filename)
reload(module) # Might be out of date during tests
del sys.path[-1]
return module
if PY33:
name = os.path.splitext(os.path.basename(fullpath))[0]
return machinery.SourceFileLoader(
name, fullpath).load_module(name)
else:
# http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html
path, filename = os.path.split(fullpath)
filename, ext = os.path.splitext(filename)
sys.path.append(path)
try:
module = __import__(filename)
reload(module) # Might be out of date during tests
return module
finally:
del sys.path[-1]

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr>=0.11,<2.0
pbr>=1.3,<2.0
# never put a cap on this, *ever*, sqla versions are handled via
# tox, and if SQLA is capped it will only make it so we aren't testing

View File

@ -16,6 +16,14 @@
import setuptools
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
setuptools.setup(
setup_requires=['pbr'],
setup_requires=['pbr>=1.3'],
pbr=True)

View File

@ -8,7 +8,7 @@ coverage>=3.6
discover
feedparser
fixtures>=0.3.14
mock>=1.0
mock>=1.2
mox>=0.5.3
psycopg2
python-subunit>=0.0.18