| Index: tools/testrunner/local/utils.py
|
| diff --git a/tools/testrunner/local/utils.py b/tools/testrunner/local/utils.py
|
| index c880dfc34ebd83dc465efe5d9166559e442e8566..3e79e44afa22bff5fb623d1cb5451b5d9cf04b81 100644
|
| --- a/tools/testrunner/local/utils.py
|
| +++ b/tools/testrunner/local/utils.py
|
| @@ -136,3 +136,24 @@ def URLRetrieve(source, destination):
|
| pass
|
| with open(destination, 'w') as f:
|
| f.write(urllib2.urlopen(source).read())
|
| +
|
| +
|
| +class FrozenDict(dict):
|
| + def __setitem__(self, *args, **kwargs):
|
| + raise Exception('Tried to mutate a frozen dict')
|
| +
|
| + def update(self, *args, **kwargs):
|
| + raise Exception('Tried to mutate a frozen dict')
|
| +
|
| +
|
| +def Freeze(obj):
|
| + if isinstance(obj, dict):
|
| + return FrozenDict((k, Freeze(v)) for k, v in obj.iteritems())
|
| + elif isinstance(obj, set):
|
| + return frozenset(obj)
|
| + elif isinstance(obj, list):
|
| + return tuple(Freeze(item) for item in obj)
|
| + else:
|
| + # Make sure object is hashable.
|
| + hash(obj)
|
| + return obj
|
|
|