Documentation: `setup` and `teardown` aren't mentioned
See original GitHub issueWhile browsing the current release docs on “xunit-style” support, specifically the usage of setup and tearing down (cleanup) of tests, I was surprised not to see setup() and teardown() mentioned. Instead, the documentation points out that for methods, one must use setup_method() and teardown_method().
I’ve always used setup() and teardown() methods for setting up and cleaning up before and after each test method in a class for production code as well as teaching Pytest.
Are those methods deprecated and shouldn’t be used? Supported by mistake? Or is it an omission in the docs? Either way the docs need to be rectified for correctness. I’m happy to provide a PR with the right path.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Teardown Clarification and/or Feature Request #1078 - GitHub
In the documentation, teardown is mentioned several times, but a clear example is never provided. I would assume that code written after a...
Read more >Using Setup and Teardown Functions - Parasoft Documentation
You can perform test case setup and cleanup actions using setUp and tearDown functions. setUp and tearDown are called before and after each ......
Read more >Setup And Teardown Scripts | ReadyAPI Documentation
Opens the Code Completion prompt. Go to Line, Moves the caret to the specified line. Show Line Numbers, Toggles whether line numbers are...
Read more >How do I correctly setup and teardown for my pytest class with ...
According to Fixture finalization / executing teardown code, the current best practice for setup and teardown is to use yield instead of return...
Read more >addTeardownBlock: | Apple Developer Documentation
Use teardown blocks to write test-specific teardown code alongside associated setup code. For example, if a test method needs to create a resource...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @alfredodeza,
Fair question.
setupandteardownwork because of the nose-style support.For example, the example below works when executing
pytest, but fails withpytest -p no:nose:So this is a nose-idiom, not a pytest-idiom.
Perhaps we need to document
setup()andteardown()more explicitly in the nose page? 🤔Not sure either, I’m not familiar with nose’s docs myself, but it certainly is supported: