From b05658735bb054c1a34a147b1e366b3e3e0076ff Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 6 Sep 2016 12:15:50 +1000 Subject: [PATCH] Enable Python 3.5 testing and fix tests Fixes to a couple of places to make the python 3.5 tests pass. Change-Id: I3f4b73b24fbe336ac6c80b7aa224a830ab7e36a6 --- horizon/utils/babel_extract_angular.py | 4 +++- openstack_dashboard/api/rest/json_encoder.py | 2 +- openstack_dashboard/settings.py | 3 ++- tox.ini | 8 +++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/horizon/utils/babel_extract_angular.py b/horizon/utils/babel_extract_angular.py index 91c1eae21b..37c1eb9aec 100644 --- a/horizon/utils/babel_extract_angular.py +++ b/horizon/utils/babel_extract_angular.py @@ -52,7 +52,9 @@ class AngularGettextHTMLParser(html_parser.HTMLParser): def __init__(self): try: - super(AngularGettextHTMLParser, self).__init__() + super(AngularGettextHTMLParser, self).__init__( + convert_charrefs=False + ) except TypeError: # handle HTMLParser not being a type on Python 2 html_parser.HTMLParser.__init__(self) diff --git a/openstack_dashboard/api/rest/json_encoder.py b/openstack_dashboard/api/rest/json_encoder.py index 06c7ba744c..2f203514e5 100644 --- a/openstack_dashboard/api/rest/json_encoder.py +++ b/openstack_dashboard/api/rest/json_encoder.py @@ -50,7 +50,7 @@ class NaNJSONEncoder(json.JSONEncoder): o = o.decode(_encoding) return _orig_encoder(o) - def floatstr(o, allow_nan=self.allow_nan, _repr=encoder.FLOAT_REPR, + def floatstr(o, allow_nan=self.allow_nan, _repr=float.__repr__, _inf=encoder.INFINITY, _neginf=-encoder.INFINITY): # Check for specials. Note that this type of test is processor # and/or platform-specific, so do tests which don't depend on the diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 0ee273a95b..419b280bfe 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -326,7 +326,8 @@ if os.path.exists(LOCAL_SETTINGS_DIR_PATH): for filename in sorted(filenames): if filename.endswith(".py"): try: - execfile(os.path.join(dirpath, filename)) + with open(os.path.join(dirpath, filename)) as f: + exec(f.read()) except Exception as e: logging.exception( "Can not exec settings snippet %s" % filename) diff --git a/tox.ini b/tox.ini index bf55ae32ff..f65566b226 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,py27dj18,py27,py34,releasenotes +envlist = pep8,py27dj18,py27,py34,py35,releasenotes minversion = 1.6 skipsdist = True @@ -45,6 +45,12 @@ setenv = {[testenv]setenv} PYTHONUNBUFFERED=1 +[testenv:py35] +basepython = python3.5 +setenv = + {[testenv]setenv} + PYTHONUNBUFFERED=1 + [testenv:pep8] usedevelop = True whitelist_externals =