-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Custom marker kwargs for test case method is overwritten from class marker. #2515
Comments
that api for the combined maks gives a legacy view and it should be avoided, deprecation warnings will be added in the next major release for using combined marks making them more complex while adding a new completely backward incompatilbe "slurp" of a parameter cant be done |
btw- for getting elemental mark objects, please take a look at https://github.com/petr-balogh/pytest/blob/a0208afa37a3f53cf60446d27348a01020b069df/_pytest/mark.py#L373 - the mark-info class also contains all non-recombined marks |
actually, after seeingthe code trough i will have to close this issue as invalid mark-info objects on functions containing merged args/kwargs is a legacy behavior that cant be removed without breaking testsuites there will be a replacement api for marks - in future |
Hi @RonnyPfannschmidt I see that mark-info class contains all non-recombined marks, that what I was printing in output of example. But I didn't find way how to distinguish which one is defined from class and which one is from method (I mean if I won't put arg "class" or "method" as I did in example). We moved from unittest some time ago, and we used to have all tests marked with specific tier I thought also about create markers like tese : tier1 = pytest.mark.tier1
tier2 = pytest.mark.tier2 but problem is that if you will have class like here: @tier1
class TestClass(object):
@tier2
def test_demo1(self):
print "Info test 1"
def test_demo2(self):
print "Info test 1" In this example you can run with pytest with parameter Could you please advise how to solve this issue? |
@petr-balogh currently there is no solution for this as this is a very long standing tructureal issue in pytest in the last few years i threw in weeks of development time to fine a solution, by now there is a path to progression but noting wokrable yet however your isuse just gave me an idea on how to provide a usefull solution ot the issue for the next pytest major release we can expose pristine non-transferred marks as function.pytestmark |
Custom marker decorator for class is not overwritten by marker from method.
Content of test_file.py
content of conftest.py
Output of pytest:
expected Results:
I tried find the way, how get information if marker comes from method or class, but didn't find anything.
I was able to do solution here: petr-balogh@a0208af but in this case, you have to specify scope='method' for that marker. Any idea how to solve this issue, or make it better? Or are you OK with this patch and can I send PR?
The text was updated successfully, but these errors were encountered: