mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1053069
- Make mozbuild.util.ReadOnlyDefaultDict raise an exception on update() and del. r=gps
This commit is contained in:
parent
7df99e7ce4
commit
3bbfbdbb84
@ -27,9 +27,7 @@ class MockConfig(object):
|
||||
'MOZ_BAR': 'bar',
|
||||
'MOZ_TRUE': '1',
|
||||
'MOZ_FALSE': '',
|
||||
})
|
||||
|
||||
self.substs.update(extra_substs)
|
||||
}, **extra_substs)
|
||||
|
||||
self.substs_unicode = ReadOnlyDict({k.decode('utf-8'): v.decode('utf-8',
|
||||
'replace') for k, v in self.substs.items()})
|
||||
|
@ -220,7 +220,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
reader = self.reader('resources')
|
||||
objs = self.read_topsrcdir(reader)
|
||||
|
||||
expected_defines = reader.config.defines
|
||||
expected_defines = dict(reader.config.defines)
|
||||
expected_defines.update({
|
||||
'FOO': True,
|
||||
'BAR': 'BAZ',
|
||||
|
@ -27,6 +27,26 @@ class TestReadOnlyDict(unittest.TestCase):
|
||||
with self.assertRaises(Exception):
|
||||
test['baz'] = True
|
||||
|
||||
def test_update(self):
|
||||
original = {'foo': 1, 'bar': 2}
|
||||
|
||||
test = ReadOnlyDict(original)
|
||||
|
||||
with self.assertRaises(Exception):
|
||||
test.update(foo=2)
|
||||
|
||||
self.assertEqual(original, test)
|
||||
|
||||
def test_del(self):
|
||||
original = {'foo': 1, 'bar': 2}
|
||||
|
||||
test = ReadOnlyDict(original)
|
||||
|
||||
with self.assertRaises(Exception):
|
||||
del test['foo']
|
||||
|
||||
self.assertEqual(original, test)
|
||||
|
||||
|
||||
class TestReadOnlyDefaultDict(unittest.TestCase):
|
||||
def test_simple(self):
|
||||
|
@ -53,9 +53,15 @@ class ReadOnlyDict(dict):
|
||||
def __init__(self, *args, **kwargs):
|
||||
dict.__init__(self, *args, **kwargs)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
def __delitem__(self, key):
|
||||
raise Exception('Object does not support deletion.')
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
raise Exception('Object does not support assignment.')
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
raise Exception('Object does not support update.')
|
||||
|
||||
|
||||
class undefined_default(object):
|
||||
"""Represents an undefined argument value that isn't None."""
|
||||
|
Loading…
Reference in New Issue
Block a user