diff --git a/tests/test_base.py b/tests/test_base.py index 8811361..e81a8d6 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -181,6 +181,18 @@ def test_add_kwargs_ignore(self): third.check({'bar': 4, 'bar1': 41}) third.check({'bar': 4, 'bar1': 41, 'eggs': 'blabla'}) + def test_add_kwargs_ignore_any(self): + first = t.Dict( + t.Key('bip', trafaret=t.String()), ignore_extra='*' + ) + second = t.Dict( + t.Key('bop', trafaret=t.Int()) + ) + + third = first + second + third.check({'bip': u'bam', 'bop': 17, 'matter': False}) + assert third.ignore_any + def test_add_kwargs_extra(self): first = t.Dict( t.Key('bar', trafaret=t.Int()), allow_extra=['eggs'] diff --git a/trafaret/base.py b/trafaret/base.py index 39a9588..5919ef9 100644 --- a/trafaret/base.py +++ b/trafaret/base.py @@ -1123,14 +1123,14 @@ def merge(self, other): Extends one Dict with other Dict Key`s or Key`s list, or dict instance supposed for Dict """ - ignore = self.ignore extra = self.extras if isinstance(other, Dict): other_keys = other.keys - ignore += other.ignore extra += other.extras + ignore = '*' if (self.ignore_any or other.ignore_any) else self.ignore + other.ignore elif isinstance(other, (list, tuple)): other_keys = list(other) + ignore = self.ignore elif isinstance(other, dict): return self.__class__(other, *self.keys) else: