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

[docs] understanding input type of e.g. pytest_runtest_setup #3414

Closed
svenevs opened this issue Apr 20, 2018 · 2 comments
Closed

[docs] understanding input type of e.g. pytest_runtest_setup #3414

svenevs opened this issue Apr 20, 2018 · 2 comments
Labels
type: docs documentation improvement, missing or needing clarification

Comments

@svenevs
Copy link
Contributor

svenevs commented Apr 20, 2018

I was writing documentation for my testing suite functions, for which in a conftest.py I am defining def pytest_runtest_setup(item) to do some setup. The actual type(item) is _pytest.unittest.TestCaseFunction, which leads me to believe there is a higher type since non-unittest functions should work too. The item.__bases__ is _pytest.python.Function.

What is the "most" base type here for item (for me to add in my docs, but also look up)? The reason I am interested is because I kind of just through the setup function together blindly. For example, I check if issubclass(item.cls, MyGlobalTestCaseClass): before doing the setup, because there is some class-level data needed to do the setup. Is item.cls I can rely on? I only found item.cls by checking with debugger, but don't know if that comes from pytest or unittest.

Sorry if this question is already answered / obvious! If it is not, and there is an ideal location to put it in the docs please let me know :)

@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #795 (Docs typo), #3145 (Understanding an IOError), #561 (SyntaxError in docs), #2435 (f), and #432 (Testing docs and doc tests).

@pytestbot pytestbot added the type: docs documentation improvement, missing or needing clarification label Apr 20, 2018
@svenevs
Copy link
Contributor Author

svenevs commented Apr 22, 2018

Ok I'm pretty sure the answer is _pytest.nodes.Item.

In my conf.py:

extensions = [
    # ...other extensions...
    'sphinx.ext.intersphinx'
]

intersphinx_mapping = {
    # ...other mappings...
    'pytest': ('https://docs.pytest.org/en/latest/', None),
}

In my documentation:

:class:`pytest:_pytest.nodes.Item`

@svenevs svenevs closed this as completed Apr 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs documentation improvement, missing or needing clarification
Projects
None yet
Development

No branches or pull requests

2 participants