Skip to content
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

should.not_have.key(...) not working properly #55

Closed
chris922 opened this issue Feb 12, 2020 · 1 comment
Closed

should.not_have.key(...) not working properly #55

chris922 opened this issue Feb 12, 2020 · 1 comment

Comments

@chris922
Copy link

In the examples the following line is given, but it asserts to a failure using grappa 0.1.10:

{'bar': True} | should.not_have.key('foo')

See https://grappa.readthedocs.io/en/latest/operators.html#keys

The following error will be shown:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
...\Python37\lib\site-packages\grappa\test.py:208: in __ror__
    return self.__overload__(value)
...\Python37\lib\site-packages\grappa\test.py:196: in __overload__
    return self.__call__(subject, overload=True)
...\Python37\lib\site-packages\grappa\test.py:73: in __call__
    return self._trigger() if overload else Test(subject)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <grappa.test.Test object at 0x00000230CAC56F60>

    def _trigger(self):
        """
        Trigger assertions in the current test engine.
    
        Raises:
            AssertionError: in case of assertion error.
            Exception: in case of any other assertion error.
        """
        log.debug('[test] trigger with context: {}'.format(self._ctx))
    
        try:
            err = self._engine.run(self._ctx)
        except Exception as _err:
            err = _err
        finally:
            # Important: reset engine state to defaults
            self._engine.reset()
            self._root._engine.reset()
    
        # If error is present, raise it!
        if err:
>           raise err
E           AssertionError: Oops! Something went wrong!
E           
E             The following assertion was not satisfied
E               subject "{'bar': True}" should not have key "foo"
E           
E             Where
E               File "...", line 11, in test_grappa_issue
E           
E               11| >     {'bar': True} | should.not_have.key('foo')
E               12|   

...\Python37\lib\site-packages\grappa\test.py:113: AssertionError

(I removed some lines of our code, so don't be confused about the line numbering)

@AndreiBarsan
Copy link

Can confirm, this check is buggy in 0.1.12!

sgissinger added a commit to sgissinger/grappa that referenced this issue Nov 17, 2020
@h2non h2non closed this as completed in 696b5e6 Nov 21, 2020
h2non added a commit that referenced this issue Nov 21, 2020
Fixes #53, #55, #48, #59 (partially) and added mock call operators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants