-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support Parameterized Pytest Tests #58
base: main
Are you sure you want to change the base?
Conversation
This commit adds support for parameterized tests in Pytest. Closes approvals#55
|
||
|
||
@pytest.fixture | ||
def pytest_verify(request): |
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 was unsure where to place this fixture, so I placed it here for now. It should probably move before the code is merged.
I had a good look at this pull request and thought about it and decided not to accept it as-is. I have pushed some changes today that add a PyTestNamer that uses the request fixture to work out where to put the approved files. I couldn't have written this without seeing your code first, so thankyou for the inspiration! If you use this namer, you get the effect you're after - that parameterized tests get the right name. I havn't added the 'pytest_verify' fixture you have added. I didn't find a good way to include it. I don't want approvaltests to stop working for people who are using unittest only. I'm thinking I might put it in the PyTest plugin (https://github.com/approvals/ApprovalTests.Python.PytestPlugin) At present it's a bit verbose to use the pytest namer. You need something like this: def test_with_pytest_namer(request): I'm hoping I can improve on that, but this is at least possible. |
How about adding an As for the tests - I think we should include a parameterized test, as that was the issue that prompted the addition of a Pytest namer. |
You make good points! I'm away over Christmas, and I will take this up again in the new year. |
@emilybache any updates? |
Hi, sorry for the long silence. I havn't felt able to prioritize working on this recently. You've made some good suggestions and I need to spend some time looking into it. |
@tmr232 We were looking at this today (sorry for the very long delay) if you would like can you join our mobbing session (sundays 10am MST) next week and we should be able to get this into the main branch and deploy it. |
e1303ae
to
91b60f5
Compare
Description
This PR adds support for parameterized tests in Pytest.
Closes #55
The solution
This is achieved by using the
request
fixture to query the current test name, and using that with a newNamer
to get the generated filenames to match the names printed by pytest.Relevant tests have been added.