Comparison with singletons should use assertIs or assertIsNone in unittests

Bug #1259023 reported by Ryo Miki
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Low
Pavlo Shchelokovskyy
python-heatclient
Fix Released
Low
Pavlo Shchelokovskyy

Bug Description

This report is applying comments in below patch (patch set 4).

https://review.openstack.org/#/c/59626/4

AssertEqual(None, AAA) should be AssertIsNone(AAA) in unittests

the same goes for True and False singletons, with appropriate usage of assertIs / assertIsNot

Changed in heat:
assignee: nobody → Pavlo Shchelokovskyy (pshchelo)
Denis M. (dmakogon)
description: updated
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

One problem, one bug please.

- Check usage of AssertEqual(expected, observed). Some codes are AssertEqual(observed, expected).
Step #2 AssertIn is more prefeable then AssertTrue in text match cases.

Changed in heat:
status: New → Triaged
importance: Undecided → Low
description: updated
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

https://bugs.launchpad.net/heat/+bug/1259292 - for assertEqual wrong order of arguments
https://bugs.launchpad.net/heat/+bug/1259295 - for assertIn instead of assertTrue

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

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

Changed in heat:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/61447
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=b7f3c62f653f3bd86171158a4ee8ddea6b629a1d
Submitter: Jenkins
Branch: master

commit b7f3c62f653f3bd86171158a4ee8ddea6b629a1d
Author: Pavlo Shchelokovskyy <email address hidden>
Date: Thu Dec 12 15:43:47 2013 +0200

    Fix comparison with singletons

    Many plases in tests code use assertEqual(AA, None),
    the same with True and False and negatives of such comparisons.

    As comparison to singletons must use `is` operator, appropriate usage
    is assertIs, assertIsNot, assertIsNone, assertIsNotNone

    These assertions are provided by the `testtools` package,
    so this change is not breaking backward compatibility with Python 2.6

    This first patch inlcudes roughly half of the files touched by these changes
    (up to and including test_n* sans `contrib` code) to ease the review.

    Partial-Bug: #1259023

    Change-Id: If6779c9230cf73ab93165a00040d1ca32d087c80

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

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

summary: - AssertEqual(None, AAA) should be AssertIsNone(AAA) in unittests
+ Comparison with singletons shoif use assertIs or assertIsNone in
+ unittests
description: updated
summary: - Comparison with singletons shoif use assertIs or assertIsNone in
+ Comparison with singletons should use assertIs or assertIsNone in
unittests
Changed in python-heatclient:
assignee: nobody → Pavlo Shchelokovskyy (pshchelo)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-heatclient (master)

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

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

Reviewed: https://review.openstack.org/62852
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=594dd453a8bc967d722be213de6f422e8e4aede4
Submitter: Jenkins
Branch: master

commit 594dd453a8bc967d722be213de6f422e8e4aede4
Author: Pavlo Shchelokovskyy <email address hidden>
Date: Wed Dec 18 13:34:31 2013 +0200

    Fix comparison with singletons

    Many plases in tests code use assertEqual(AA, None),
    the same with True and False and negatives of such comparisons.

    As comparison to singletons must use `is` operator, appropriate usage
    is assertIs, assertIsNot, assertIsNone, assertIsNotNone

    These assertions are provided by the `testtools` package,
    so this change is not breaking backward compatibility with Python 2.6

    This second patch inlcudes the other half of the files touched by these
    changes to ease the review.

    Change-Id: I9965ae158f3e0dc49b93b9357a32a302ac7dc735
    Closes-Bug: #1259023

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

Reviewed: https://review.openstack.org/64038
Committed: https://git.openstack.org/cgit/openstack/python-heatclient/commit/?id=a911f577daf1b6f9d76f8a4334ee5a471acc06e6
Submitter: Jenkins
Branch: master

commit a911f577daf1b6f9d76f8a4334ee5a471acc06e6
Author: Pavlo Shchelokovskyy <email address hidden>
Date: Wed Dec 25 16:21:12 2013 +0200

    Fix comparison with singletons

    Many places in tests code use assertEqual(AA, None),
    the same with True and False and negatives of such comparisons.

    As comparison to singletons must use `is` operator, appropriate usage
    is assertIs, assertIsNot, assertIsNone, assertIsNotNone

    These assertions are provided by the `testtools` package,
    so this change is not breaking backward compatibility with Python 2.6

    Change-Id: I232136ce49afdb8bf78b42221454540471d12c23
    Closes-Bug: #1259023

Thierry Carrez (ttx)
Changed in heat:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Changed in python-heatclient:
importance: Undecided → Low
milestone: none → v0.2.7
Changed in python-heatclient:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: icehouse-2 → 2014.1
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.