-
Notifications
You must be signed in to change notification settings - Fork 42
Increase test coverage of Guards to 100%. #75
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
Conversation
|
travis-ci errors will be fixed by another pull request by icemac. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for improving the coverage. 👍
tests/test_Guards.py
Outdated
| __metaclass__=type, | ||
| _write_=lambda x: x, | ||
| _getattr_=getattr) | ||
| _getattr_=getattr,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not necessary.
tests/test_Guards.py
Outdated
| assert restricted_globals['b'] == '2411' | ||
|
|
||
|
|
||
| class D: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The classes should have more meaningful values. If the are only needed for one test they could be moved into the test function together with the code which uses them.
tests/test_Guards.py
Outdated
| assert None is restricted_globals['d1'].value | ||
|
|
||
|
|
||
| class E: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
tests/test_Guards.py
Outdated
| assert 'attribute-less object (assign or del)' in str(excinfo.value) | ||
|
|
||
|
|
||
| class F: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
tests/test_Guards.py
Outdated
| def test_Guards__safe_builtins__3(e_exec): | ||
| """It allows use setattr and delattr when _guarded_writes is True. | ||
| `__build_class__` is only needed in Python 3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any __build_class__ usage in this test.
tests/test_Guards.py
Outdated
|
|
||
|
|
||
| @pytest.mark.parametrize(*e_exec) | ||
| def test_Guards__safe_builtins__3(e_exec): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be called test_Guards__guarded_setattr__1 as it actually tests guarded_setattr.
|
|
||
| @pytest.mark.parametrize(*e_exec) | ||
| def test_Guards__safe_builtins__3(e_exec): | ||
| """It allows use setattr and delattr when _guarded_writes is True. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delattr test could be moved to another test function.
tests/test_Guards.py
Outdated
|
|
||
| @pytest.mark.parametrize(*e_exec) | ||
| def test_Guards__write_wrapper__1(e_exec): | ||
| """It wraps it when it is not marked with _guarded_writes.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"It wraps it" ... what is it?
tests/test_Guards.py
Outdated
|
|
||
| @pytest.mark.parametrize(*e_exec) | ||
| def test_Guards__write_wrapper__2(e_exec): | ||
| """It wraps it and it works when guarded_setattr is implemented.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
tests/test_Guards.py
Outdated
| @pytest.mark.parametrize(*e_exec) | ||
| def test_Guards__guarded_unpack_sequence__1(e_exec, mocker): | ||
| """It does not protect unpacking when the sequence is shorter | ||
| than expected.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should explain why this is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fertig
No description provided.