Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderedDict mutated during iteration causing unit tests to fail. #124

Open
adam-fineman opened this issue Feb 2, 2020 · 1 comment
Open

Comments

@adam-fineman
Copy link

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 = <test_client.TestRTCClient object at 0x7fca9fe05080>
myrtcclient = <RTCClient RTC Server at http://test.url:9443/jazz>
mocker = <pytest_mock.plugin.MockFixture object at 0x7fca9fe826a0>

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 = <Templater Templater for RTC Server at http://test.url:9443/jazz>
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 = <test_template.TestTemplater object at 0x7fca9fec79e8>
mytemplater = <Templater Templater for RTC Server at http://test.url:9443/jazz>
mocker = <pytest_mock.plugin.MockFixture object at 0x7fca9fec7278>

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 = <Templater Templater for RTC Server at http://test.url:9443/jazz>
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

@adam-fineman
Copy link
Author

Pull request coming.

adam-fineman added a commit to adam-fineman/rtcclient that referenced this issue Feb 2, 2020
`tox pep8,py27,py36` now passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant