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
Issue #1201 Added improved test_function_new decorator #1238
Conversation
fa46263
to
fa8a455
Compare
fa8a455
to
c5d0fb3
Compare
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.
So far I have not used the general code you created but am trying to incorporate it into the test_wbemconnection_mock tests. Until I get that done I will not really be able to comment but in general this is a logical set of commonality for us.
42912c2
to
b3706d6
Compare
The discussion of pytest issue pytest-dev/pytest#3435 revealed how this can be done. Implemented the suggestion. |
b3df078
to
70b061f
Compare
70b061f
to
077a735
Compare
077a735
to
7772282
Compare
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 I made mistake in one comment about ordering of decorators. Statement was correct but I think I stated the wrong order.
My comments are minor and purely editorial except changing name of the decorator. I don't have better name now but that name will stay with us.
testsuite/pytest_extensions.py
Outdated
@@ -137,3 +161,146 @@ def test_CIMClass_equal( | |||
|
|||
ret = None # Debugging hint | |||
return ret | |||
|
|||
|
|||
def test_function_new(test_func): |
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.
Since this is probably what will be the major test function decorator in the future, shouldn't we call it something else that _new. Expanded, complete, 2. Not sure of name but new is just transitional as a name.
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.
We agreed to remove the old function and to name zhe new function simplified_test_function()
.
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.
DONE
testsuite/pytest_extensions.py
Outdated
|
||
Notes: | ||
|
||
* Using this decorator together with the `pytest.mark.parametrize` |
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.
How about when applying this decorator with param... this decorator must be inserted before the param... decorator
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.
Should be inserted after the param, not before.
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.
DONE.
testsuite/test_nocasedict.py
Outdated
# The code to be tested | ||
act_value = obj[key] | ||
|
||
# Verify that an exception raised in this function is not mistaken | ||
# to be the expected exception | ||
assert exp_exc_types is None | ||
assert testcase.exp_exc_types is None |
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.
comment on line above. 'mistaken as the expected exception.
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.
DONE, plus changed verify to ensure
testsuite/test_nocasedict.py
Outdated
# The code to be tested | ||
obj[key] = value | ||
|
||
# Verify that an exception raised in this function is not mistaken | ||
# to be the expected exception | ||
assert exp_exc_types is None | ||
assert testcase.exp_exc_types is None |
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.
see above
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.
DONE
The `pytest_extensions.test_function` decorator was signature-preserving. This caused the decorated test functions to have unused arguments, and access to the `kwargs` dict in the test function needed to by key access to the `kwargs` dict, causing extra code in the test functions. This change renames the decorator to `simplified_test_function` and improves the interface of the test functions which now get the testcase tuple as a named tuple, and the `kwargs` dict of the testcase as expanded keyword arguments. Note that the changed decorator needs to explicitly set the `__signature__` attribute of the test function, because the `signature()` function used by pytest uses the signature of the unpacked wrapped function. See also pytest issue #3435. Increased the minimum versions for development packages: Package "pytest" from 3.0.7 to 3.3.0 (due to the support for `signature()`) and package "py" from 1.4.32 to 1.5.1 (because that is the minimum version required by "pytest"). Signed-off-by: Andreas Maier <maiera@de.ibm.com>
7772282
to
901c0fe
Compare
The latest commit addresses all comments |
For details, see the commit message.
Ready for review and merge.