-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary keys by variable is throwing exception #48
Comments
What's the type/value of |
@h2non I can reproduce. Please take a look, I tried to make this as approachable as possible In this case it comes down to some wrong assumptions in grappa/grappa/operators/keys.py Lines 50 to 55 in 1caa121
In my example, the operators' |
Trying to assert a dictionary to not contain keys from a list of keys
data | should.not_have.key(key)
is throwing AssertionError
`test_ddt.py:19: in _runtestmodule
matchrsi(cfg.result[0], data)
......\modules\matchrsi.py:32: in matchrsi
data | should.not_have.key(key)
C:\Program Files\Python37\lib\site-packages\grappa\test.py:208: in ror
return self.overload(value)
C:\Program Files\Python37\lib\site-packages\grappa\test.py:196: in overload
return self.call(subject, overload=True)
C:\Program Files\Python37\lib\site-packages\grappa\test.py:73: in call
return self._trigger() if overload else Test(subject)
self = <grappa.test.Test object at 0x0000026784443C88>
E AssertionError: Oops! Something went wrong!
E
E The following assertion was not satisfied
E subject "{'id': 'de83e969-504 ..." should not have key "restrictionReason"
E
E Where
E File "D:\workspace\isswtest\issw-functest\modules\matchrsi.py", line 32, in matchrsi
E
E 24| empty_attr = [k for k, v in rsi.Attributes.items() if v is None]
E 25| nonempty_attr = [k for k, v in rsi.Attributes.items() if v is not None]
E 26| else:
E 27| empty_attr = nonempty_attr = []
E 28|
E 29| if rsi.object_exist:
E 30| is_xobject(data)
E 31| for key in empty_attr:
E 32| > data | should.not_have.key(key)
E 33| list(data.keys()) | should.do_not.contain(key)
E 34|
E 35| for key in nonempty_attr:
E 36| data | should.have.key(key)
E 37| data.get(key) | should.be.equal.to(rsi.Attributes.get(key))
E 38| else:
E 39| # RSI Object does not exist
C:\Program Files\Python37\lib\site-packages\grappa\test.py:113: AssertionError`
Alternatively using
list(data.keys()) | should.do_not.contain(key)
is working though
The text was updated successfully, but these errors were encountered: