From b3efa1465cd73db4e42ae2080854e3bbc3a7b198 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 27 Mar 2018 19:10:35 +0000 Subject: [PATCH] Fix the gate Following PyCQA/astroid@206d8a2 we sarted getting a whole bunch of errors like E:266,44: Value 'headers' doesn't support membership test and E:267,25: Value 'headers' is unsubscriptable Digging around a bit, apparently astroid thinks the headers returned from call_app will always be None -- I guess it doesn't like our use of a list to work around py2's lack of `nonlocal`. By using a proper object to encapsulate state, we can shut up those "error"s. Also, pin upper-constraints to pike for keystone-related jobs. Change-Id: I5ff21260872f4089b030cd94e494dc346ae74b8e --- swift3/test/unit/__init__.py | 18 ++++++++++-------- tox.ini | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/swift3/test/unit/__init__.py b/swift3/test/unit/__init__.py index 9d352a5f..bbe24daa 100644 --- a/swift3/test/unit/__init__.py +++ b/swift3/test/unit/__init__.py @@ -118,14 +118,16 @@ class Swift3TestCase(unittest.TestCase): req.headers.setdefault("User-Agent", "Mozzarella Foxfire") - status = [None] - headers = [None] + class StartResponseContext(object): + status = headers = None - def start_response(s, h, ei=None): - status[0] = s - headers[0] = swob.HeaderKeyDict(h) + def __call__(self, s, h, ei=None): + self.status = s + self.headers = swob.HeaderKeyDict(h) - body_iter = app(req.environ, start_response) + sr = StartResponseContext() + + body_iter = app(req.environ, sr) body = '' caught_exc = None try: @@ -138,9 +140,9 @@ class Swift3TestCase(unittest.TestCase): raise if expect_exception: - return status[0], headers[0], body, caught_exc + return sr.status, sr.headers, body, caught_exc else: - return status[0], headers[0], body + return sr.status, sr.headers, body def call_swift3(self, req, **kwargs): return self.call_app(req, app=self.swift3, **kwargs) diff --git a/tox.ini b/tox.ini index 31f4350e..068e26fb 100644 --- a/tox.ini +++ b/tox.ini @@ -32,6 +32,7 @@ setenv = {[testenv]setenv} commands = /bin/bash {posargs:swift3/test/functional/run_test.sh} setenv = {[testenv]setenv} AUTH=keystone + UPPER_CONSTRAINTS_FILE=https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike # keystone 12.0.0 (pike) from openstack.org deps = {[testenv]deps} @@ -63,8 +64,7 @@ setenv = {[testenv]setenv} [testenv:s3tests_keystone] commands = /bin/bash {posargs:swift3/test/functional/run_test.sh} -setenv = {[testenv]setenv} - AUTH=keystone +setenv = {[testenv:keystone]setenv} S3ACL=true DNS_BUCKET_NAMES=false CHECK_BUCKET_OWNER=true