OrderedDict mutated during iteration causing unit tests to fail.
- Dominant language
- Python
- Stars
- 40
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
Running the unit tests against py36 (I don't have py33 installed), I see the following failures:
=================================== FAILURES ===================================
_________________ TestRTCClient.test_list_fields_from_workitem _________________
self =
myrtcclient =
mocker =
def test_list_fields_from_workitem(self, myrtcclient,
mocker):
mocked_get = mocker.patch("requests.get")
mock_resp = mocker.MagicMock(spec=requests.Response)
mock_resp.status_code = 200
mock_resp.content = utils_test.workitem1_raw
mocked_get.return_value = mock_resp
fields = myrtcclient.listFieldsFromWorkitem(161,
> keep=False)
tests/test_client.py:1435:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py36/lib/python3.6/site-packages/rtcclient/client.py:879: in listFieldsFromWorkitem
keep=keep)
.tox/py36/lib/python3.6/site-packages/rtcclient/template.py:180: in listFieldsFromWorkitem
keep=keep)
.tox/py36/lib/python3.6/site-packages/rtcclient/template.py:270: in getTemplate
self._remove_long_fields(wk_raw_data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
wk_raw_data = OrderedDict([('@rdf:resource', 'http://test.url:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/161'), ('rt...://test.url:9443/jazz/oslc/workitems/161/rtc_cm:com.ibm.team.enterprise.promotion.linktype.resultWorkItem.result')]))])
def _remove_long_fields(self, wk_raw_data):
"""Remove long fields: These fields are can only customized after
the workitems are created
"""
match_str_list = ["rtc_cm:com.ibm.",
"calm:"]
> for key in wk_raw_data.keys():
E RuntimeError: OrderedDict mutated during iteration
.tox/py36/lib/python3.6/site-packages/rtcclient/template.py:354: RuntimeError
_______________________ TestTemplater.test_get_template ________________________
self =
mytemplater =
mocker =
def test_get_template(self, mytemplater, mocker):
# invalid template names
invalid_names = [None, True, False, "", u"", 123.4]
for invalid_name in invalid_names:
with pytest.raises(BadValue):
mytemplater.getTemplate(invalid_name,
template_name=None,
template_folder=None,
keep=False,
encoding="UTF-8")
# valid template name
mocked_get = mocker.patch("requests.get")
mock_resp = mocker.MagicMock(spec=requests.Response)
mock_resp.status_code = 200
mock_resp.content = utils_test.workitem1_raw
mocked_get.return_value = mock_resp
copied_from_valid_names = [161, "161", u"161"]
for copied_from in copied_from_valid_names:
template_161 = mytemplater.getTemplate(copied_from,
template_name=None,
template_folder=None,
keep=False,
> encoding="UTF-8")
tests/test_template.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py36/lib/python3.6/site-packages/rtcclient/template.py:270: in getTemplate
self._remove_long_fields(wk_raw_data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
wk_raw_data = OrderedDict([('@rdf:resource', 'http://test.url:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/161'), ('rt...://test.url:9443/jazz/oslc/workitems/161/rtc_cm:com.ibm.team.enterprise.promotion.linktype.resultWorkItem.result')]))])
def _remove_long_fields(self, wk_raw_data):
"""Remove long fields: These fields are can only customized after
the workitems are created
"""
match_str_list = ["rtc_cm:com.ibm.",
"calm:"]
> for key in wk_raw_data.keys():
E RuntimeError: OrderedDict mutated during iteration
.tox/py36/lib/python3.6/site-packages/rtcclient/template.py:354: RuntimeError
------------------------------ Captured log call -------------------------------
ERROR template.Templater:template.py:240 Please input a valid workitem id you want to copy from
ERROR template.Templater:template.py:240 Please input a valid workitem id you want to copy from
ERROR template.Templater:template.py:240 Please input a valid workitem id you want to copy from
ERROR template.Templater:template.py:240 Please input a valid workitem id you want to copy from
ERROR template.Templater:template.py:240 Please input a valid workitem id you want to copy from
ERROR template.Templater:template.py:240 Please input a valid workitem id you want to copy from
========================= 2 failed, 83 passed in 2.88s =========================
ERROR: InvocationError for command /home/afineman/work/rtcclient/.tox/py36/bin/py.test -v (exited with code 1)
___________________________________ summary ____________________________________
ERROR: py36: commands failed
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.