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
fix #2540, introduce mark.with_args #2600
fix #2540, introduce mark.with_args #2600
Conversation
86a1cb1
to
0e3d220
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.
Looks like a good-enough solution to the problem, nice!
This needs a CHANGELOG entry and some docs
class SomeClass(object): | ||
pass | ||
|
||
assert pytest.mark.fun(some_function) is some_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.
We should also verify that the mark is correctly assigned I think
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.
other tests do that
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.
fair enough
pass | ||
|
||
assert pytest.mark.fun(some_function) is some_function | ||
assert pytest.mark.fun.with_args(some_function) is not some_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.
Probably safer to test that it is a MarkInfo
object
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 merely want to assert return value behavior, the test as is is sufficient and minimal
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 merely want to assert return value behavior, the test as is is sufficient and minimal
Until someone refactors the code and this starts to return not some_function
but also not a MarkInfo
, and then unexpected breakage occurs. 😜
But OK then.
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.
uhm, other tests should catch that - if all tests test all the things we overcover and make change hard
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 might be misunderstanding the change then, because IIUC pytest.mark.fun.with_args(some_function)
is a new feature (so no other tests use it yet) and we expect it to return a MarkInfo
, but we are not making that assertion anywhere.
But no biggie really, if you think this is fine no worries.
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 ensured mark.__call__
is using it ^^ after all its an extraction of the tail of that 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.
Oh right right, sorry for the noise. 😁
0e3d220
to
65b2de1
Compare
@@ -0,0 +1 @@ | |||
Introduce ``mark.with_args`` in order to allow passing functions/classes as sole argument to marks. |
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.
Shouldn't we add some docs as well, preferably with an example?
this extracts the bit about adding params and exposes it in a unconditional way