Sort child versions before generating fingerprint
We need to sort the version dictionary to ensure py27 and py34 generate the same fingerprint. Depends-On: I0f07858e96ea3baf46f8a453e253b9ed29c7f7e2 Depends-On: I33bd2d9dff9cb7dc1a50177db7286b7317966784 Change-Id: I0adc3d696c90dfe20d35bdf06f033eb3a2491fd0
This commit is contained in:
parent
520b4496fb
commit
adb66403bd
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
import hashlib
|
||||
import inspect
|
||||
import logging
|
||||
@ -145,7 +146,9 @@ class ObjectVersionChecker(object):
|
||||
# but many other things may require a version bump (method behavior
|
||||
# and return value changes, for example).
|
||||
if hasattr(obj_class, 'child_versions'):
|
||||
relevant_data = (obj_fields, methods, obj_class.child_versions)
|
||||
relevant_data = (obj_fields, methods,
|
||||
OrderedDict(
|
||||
sorted(obj_class.child_versions.items())))
|
||||
else:
|
||||
relevant_data = (obj_fields, methods)
|
||||
fingerprint = '%s-%s' % (obj_class.VERSION, hashlib.md5(
|
||||
|
@ -149,6 +149,16 @@ class RandomMixInWithNoFields(object):
|
||||
@base.VersionedObjectRegistry.register
|
||||
class TestSubclassedObject(RandomMixInWithNoFields, MyObj):
|
||||
fields = {'new_field': fields.Field(fields.String())}
|
||||
child_versions = {
|
||||
'1.0': '1.0',
|
||||
'1.1': '1.1',
|
||||
'1.2': '1.1',
|
||||
'1.3': '1.2',
|
||||
'1.4': '1.3',
|
||||
'1.5': '1.4',
|
||||
'1.6': '1.5',
|
||||
'1.7': '1.6',
|
||||
}
|
||||
|
||||
|
||||
class TestRegistry(test.TestCase):
|
||||
@ -421,7 +431,7 @@ class TestFixture(_BaseTestCase):
|
||||
hashes = checker.get_hashes()
|
||||
# NOTE(danms): If this object's version or hash changes, this needs
|
||||
# to change. Otherwise, leave it alone.
|
||||
self.assertEqual('1.6-b56dbb7efe42a7ceb137d958fc4066cf',
|
||||
self.assertEqual('1.6-7157ceb869f8f63fb9a955e6a7080ad7',
|
||||
hashes['TestSubclassedObject'])
|
||||
|
||||
def test_test_hashes(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user