Unit tests are not passing under python3.7

Bug #1814890 reported by Michal Arbet on 2019-02-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-magnumclient
Undecided
Michal Arbet

Bug Description

Hi,

I'm packaging packages for debian and found that unit tests are failing under py37.

Request to create cluster 3a369884-b6ba-484f-a206-919b4b718aff accepted

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_server_success_body_json
magnumclient.tests.test_httpclient.HttpClientTest.test_server_success_body_json
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 347, in test_server_success_body_json
    resp, body = client.json_request('GET', '/v1/resources')
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_server_exception_msg_only
magnumclient.tests.test_httpclient.HttpClientTest.test_server_exception_msg_only
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 109, in test_server_exception_msg_only
    'GET', '/v1/resources')
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 485, in assertRaises
    self.assertThat(our_callable, matcher)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 496, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 547, in _matchHelper
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 108, in match
    mismatch = self.exception_matcher.match(exc_info)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 475, in match
    reraise(*matchee)
  File "/usr/lib/python3/dist-packages/testtools/_compat3x.py", line 16, in reraise
    raise exc_obj.with_traceback(exc_tb)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 101, in match
    result = matchee()
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 1049, in __call__
    return self._callable_object(*self._args, **self._kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_server_exception_empty_body
magnumclient.tests.test_httpclient.HttpClientTest.test_server_exception_empty_body
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 93, in test_server_exception_empty_body
    'GET', '/v1/resources')
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 485, in assertRaises
    self.assertThat(our_callable, matcher)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 496, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 547, in _matchHelper
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 108, in match
    mismatch = self.exception_matcher.match(exc_info)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 475, in match
    reraise(*matchee)
  File "/usr/lib/python3/dist-packages/testtools/_compat3x.py", line 16, in reraise
    raise exc_obj.with_traceback(exc_tb)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 101, in match
    result = matchee()
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 1049, in __call__
    return self._callable_object(*self._args, **self._kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_server_body_undecode_json
magnumclient.tests.test_httpclient.HttpClientTest.test_server_body_undecode_json
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 307, in test_server_body_undecode_json
    resp, body = client.json_request('GET', '/v1/resources')
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_server_success_body_none
magnumclient.tests.test_httpclient.HttpClientTest.test_server_success_body_none
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 333, in test_server_success_body_none
    resp, body = client.json_request('GET', '/v1/resources')
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_server_exception_msg_and_traceback
magnumclient.tests.test_httpclient.HttpClientTest.test_server_exception_msg_and_traceback
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 128, in test_server_exception_msg_and_traceback
    'GET', '/v1/resources')
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 485, in assertRaises
    self.assertThat(our_callable, matcher)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 496, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 547, in _matchHelper
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 108, in match
    mismatch = self.exception_matcher.match(exc_info)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 475, in match
    reraise(*matchee)
  File "/usr/lib/python3/dist-packages/testtools/_compat3x.py", line 16, in reraise
    raise exc_obj.with_traceback(exc_tb)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 101, in match
    result = matchee()
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 1049, in __call__
    return self._callable_object(*self._args, **self._kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

======================================================================
FAIL: magnumclient.tests.test_httpclient.HttpClientTest.test_401_unauthorized_exception
magnumclient.tests.test_httpclient.HttpClientTest.test_401_unauthorized_exception
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 409, in __iter__
    yield self.next()
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 421, in next
    raise StopIteration()
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/magnumclient/tests/test_httpclient.py", line 281, in test_401_unauthorized_exception
    'GET', '/v1/resources')
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 485, in assertRaises
    self.assertThat(our_callable, matcher)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 496, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 547, in _matchHelper
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 108, in match
    mismatch = self.exception_matcher.match(exc_info)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 475, in match
    reraise(*matchee)
  File "/usr/lib/python3/dist-packages/testtools/_compat3x.py", line 16, in reraise
    raise exc_obj.with_traceback(exc_tb)
  File "/usr/lib/python3/dist-packages/testtools/matchers/_exception.py", line 101, in match
    result = matchee()
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 1049, in __call__
    return self._callable_object(*self._args, **self._kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 233, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 203, in _http_request
    else chunk for chunk in body_iter
  File "/<<PKGBUILDDIR>>/magnumclient/common/httpclient.py", line 202, in <listcomp>
    chunk.decode("utf-8") if isinstance(chunk, bytes)
RuntimeError: generator raised StopIteration

----------------------------------------------------------------------
Ran 454 tests in 4.101s

This can be fixed by replacing StopIteration with return as it is in pep:

https://www.python.org/dev/peps/pep-0479/

Changed in python-magnumclient:
assignee: nobody → Michal Arbet (michalarbet)

This issue was fixed in the openstack/python-magnumclient 2.12.0 release.

Changed in python-magnumclient:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers