malformed assert message in assert_called_anytime

Bug #1210296 reported by Peter Hamilton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cinderclient
Fix Released
Undecided
Peter Hamilton

Bug Description

Location: cinderclient/tests/fakes/FakeClient
Method: assert_called_anytime

The following statement raises a TypeError when "found = False":

assert found, 'Expected %s %s; got %s' % (expected, self.client.callstack)

This occurs because "expected" is a tuple and does not get expanded properly when nested within another tuple. To fix, I propose wrapping the callstack argument in a single-element tuple and joining the two together:

assert found, 'Expected %s %s; got %s' % (expected + (self.client.callstack, ))

Tags: test
Changed in python-cinderclient:
assignee: nobody → Peter Hamilton (peter-hamilton)
tags: added: test
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-cinderclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/41525

Changed in python-cinderclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-cinderclient (master)

Reviewed: https://review.openstack.org/41525
Committed: http://github.com/openstack/python-cinderclient/commit/eb413f5373af70cbd41a0f9bf0800cf47d609dcc
Submitter: Jenkins
Branch: master

commit eb413f5373af70cbd41a0f9bf0800cf47d609dcc
Author: Peter Hamilton <email address hidden>
Date: Mon Aug 12 09:05:44 2013 -0400

    Fixing malformed assert message formatting

    This modification addresses Bug #1210296, specifically addressing
    malformed assert message formatting in assert_called_anytime. When
    verifying that an API method was called during test execution, the
    assert statement used will throw a TypeError when formatting the
    assert message, instead of the expected AssertionError. This occurs
    because a nested tuple in the format list is not properly expanded.
    The error itself likely exists because assert_called_anytime is not
    currently used in the python-cinderclient testing framework.

    The fix involves joining the arguments in the format list into a
    single tuple, allowing proper argument expansion.

    Fixes: bug 1210296

    Change-Id: I6cf9dd55cff318e8a850637c540436c91dac08df

Changed in python-cinderclient:
status: In Progress → Fix Committed
Changed in python-cinderclient:
milestone: none → 1.3.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.