Unit test: self.assertNotEqual in unit.test_base.BaseTest.test_eq does not work in PY2
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Kosmos |
New
|
Undecided
|
Unassigned | ||
Panko |
Fix Released
|
Undecided
|
Hanxi Liu | ||
daisycloud-core |
New
|
Undecided
|
Unassigned | ||
octavia |
Fix Released
|
Low
|
Ji.Wei | ||
python-congressclient |
Fix Released
|
Undecided
|
Yafei Yu | ||
python-karborclient |
Fix Released
|
Undecided
|
Yafei Yu | ||
python-muranoclient |
Fix Released
|
Undecided
|
Yafei Yu | ||
taskflow |
Fix Released
|
Undecided
|
Ji.Wei |
Bug Description
Version: master(20160527)
In case cinderclient.
Class base.Resource defines __eq__() built-in function, but does not define __ne__() built-in function, so self.assertEqual works but self.assertNotEqual does not work at all in this test case.
steps:
1 Clone code of python-cinderclient from master.
2 Modify the case of unit test: cinderclient/
line50--line62.
def test_eq(self):
# Two resources with same ID: never equal if their info is not equal
r1 = base.Resource(None, {'id': 1, 'name': 'hi'})
r2 = base.Resource(None, {'id': 1, 'name': 'hello'})
# Two resources with same ID: equal if their info is equal
r1 = base.Resource(None, {'id': 1, 'name': 'hello'})
r2 = base.Resource(None, {'id': 1, 'name': 'hello'})
# self.assertEqua
# Two resoruces of different types: never equal
r1 = base.Resource(None, {'id': 1})
r2 = volumes.
# Two resources with no ID: equal if their info is equal
r1 = base.Resource(None, {'name': 'joe', 'age': 12})
r2 = base.Resource(None, {'name': 'joe', 'age': 12})
# self.assertEqua
Modify self.assertEqua
3 Run unit test, and return success.
After that, I make a test:
class Resource(object):
def __init__(self, person):
self.person = person
def __eq__(self, other):
return self.person == other.person
r1 = Resource("test")
r2 = Resource("test")
r3 = Resource("test_r3")
r4 = Resource("test_r4")
print r1 != r2
print r1 == r2
print r3 != r4
print r3 == r4
The result is :
True
True
True
False
Whether r1 is precisely the same to r2 or not, self.assertNotE
tags: | added: unittest |
description: | updated |
Changed in python-cinderclient: | |
assignee: | nobody → jingtao liang (liang-jingtao) |
Changed in python-cinderclient: | |
status: | New → In Progress |
description: | updated |
description: | updated |
tags: |
added: tests removed: unittest |
Changed in python-cinderclient: | |
assignee: | jingtao liang (liang-jingtao) → yuyafei (yu-yafei) |
description: | updated |
summary: |
- Unit test: unit.test_base.BaseTest.test_eq does not work + Unit test: self.assertNotEqual in unit.test_base.BaseTest.test_eq does + not work |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in python-novaclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-keystoneclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-heatclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-manilaclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
summary: |
Unit test: self.assertNotEqual in unit.test_base.BaseTest.test_eq does - not work + not work in PY2 |
Changed in python-glanceclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-troveclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-muranoclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in tempest: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in nova: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in ceilometer: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in neutron: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in swift: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in rally: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in python-congressclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-congressclient: | |
assignee: | yuyafei (yu-yafei) → Ji.Wei (jiwei) |
Changed in python-smaugclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-congressclient: | |
assignee: | Ji.Wei (jiwei) → nobody |
no longer affects: | cloudkitty |
Changed in daisycloud-core: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in keystonemiddleware: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in keystone: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in heat: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in glance: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in python-ceilometerclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in python-congressclient: | |
assignee: | nobody → yuyafei (yu-yafei) |
Changed in cinder: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in python-swiftclient: | |
assignee: | nobody → Ji.Wei (jiwei) |
no longer affects: | python-cloudkittyclient (Ubuntu) |
Changed in horizon: | |
assignee: | nobody → Ji.Wei (jiwei) |
no longer affects: | cinder |
no longer affects: | keystone |
no longer affects: | rally |
Changed in nova: | |
assignee: | yuyafei (yu-yafei) → Ji.Wei (jiwei) |
Changed in python-novaclient: | |
assignee: | yuyafei (yu-yafei) → Andrey Kurilin (andreykurilin) |
no longer affects: | glance |
no longer affects: | swift |
no longer affects: | python-swiftclient |
no longer affects: | keystonemiddleware |
no longer affects: | python-keystoneclient |
no longer affects: | python-troveclient |
Changed in panko: | |
assignee: | nobody → Hanxi Liu (hanxi-liu) |
Changed in gnocchi: | |
assignee: | nobody → Hanxi Liu (hanxi-liu) |
Changed in octavia: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in kosmos: | |
assignee: | nobody → Ji.Wei (jiwei) |
Changed in taskflow: | |
assignee: | nobody → Ji.Wei (jiwei) |
no longer affects: | gnocchi |
no longer affects: | neutron |
Changed in kosmos: | |
assignee: | Ji.Wei (jiwei) → nobody |
Changed in daisycloud-core: | |
assignee: | Ji.Wei (jiwei) → nobody |
Fix proposed to branch: master /review. openstack. org/322376
Review: https:/