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

fails on decorated methods #58

Closed
davidszotten opened this issue Nov 23, 2017 · 9 comments
Closed

fails on decorated methods #58

davidszotten opened this issue Nov 23, 2017 · 9 comments
Assignees

Comments

@davidszotten
Copy link

Hi,

i have something like

class TestClass(object):
    @pytest.mark.django_db()
    def test_method(self):
        pass

when running Pytest method i get py.test ==> Running test for parametrized method test_method but it actually tries to run 'path/to/file.py'::TestClass

@alfredodeza
Copy link
Owner

The message is a bit misleading because it does call out to the class and then it filters by the method name. This is because py.test doesn't have support for parametrized test methods using the 'path/to/test.py::TestClass::test_method

Do you have unexpected execution of the parametrized test? Or does it execute and you are just worried about the message? Does :Pytest session look ok/expected ?

If this is about the messaging, I could improve it a bit I think, to signal that it is working with a parametrized method.

@davidszotten
Copy link
Author

hey, thanks for the quick reply. and apologies if i wasn't clear: the point is that the test isn't parametrized at all, that's a regular pytest mark

@alfredodeza alfredodeza self-assigned this Nov 23, 2017
@alfredodeza
Copy link
Owner

Ouch. Of course. We are being naive trying to detect this. I can get a fix so you can try it out in a bit, thanks for clarifying!

@davidszotten
Copy link
Author

thank you!

@alfredodeza
Copy link
Owner

@davidszotten can you try a7abab2 and tell me if that fixes this for you? I can then merge to master and hopefully close this ticket :)

@davidszotten
Copy link
Author

yes, this seems to fix the issue

i don't quite follow why parametrized functions need special handling, from what i see they can be invoked just like non-parametrized ones

@alfredodeza
Copy link
Owner

This is because py.test can't use the notation of /path/test_file.py::TestClass:test_method when test_method is parametrized. I think this is because internally py.test is having signature for each parametrized execution.

That is why we use -k in this case, to specify up to the class, and then filter the test method with -k

Thanks for reporting this! Will push this to master

@alfredodeza
Copy link
Owner

This is the issue I reported a while back pytest-dev/pytest#649

Seems to have been fixed recently, but I have to supported older versions of py.test so this has workaround has to stay for now

@davidszotten
Copy link
Author

ah yes. looks like it was fixed in 2.9.1 (2016-03-17)

anyway. thanks for the fix for my current issue!

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