Skip to content

Support non-function test items in pytest_runtest_setup - #107

Closed
orf wants to merge 2 commits into
miketheman:mainfrom
orf:patch-1
Closed

orf wants to merge 2 commits into
miketheman:mainfrom
orf:patch-1

Conversation

@orf

@orf orf commented Jan 20, 2022

Copy link
Copy Markdown
Contributor

pytest-dev/pytest#5070 for more information

If you run pytest with --doctest-modules this will cause the following exception to be raised:

item = <DoctestItem foo.bar>
    def pytest_runtest_setup(item) -> None:
        """During each test item's setup phase,
        choose the behavior based on the configurations supplied.
    
        This is the bulk of the logic for the plugin.
        As the logic can be extensive, this method is allowed complexity.
        It may be refactored in the future to be more readable.
        """
    
        # If test has the `enable_socket` marker, we accept this as most explicit.
>       if "socket_enabled" in item.fixturenames or item.get_closest_marker(
            "enable_socket"
        ):
E       AttributeError: 'DoctestItem' object has no attribute 'fixturenames'

Also thank you for the great library 🙏

@qlty-cloud-legacy

Copy link
Copy Markdown

Code Climate has analyzed commit 40a2bf7 and detected 0 issues on this pull request.

View more on Code Climate.

@miketheman

Copy link
Copy Markdown
Owner

Thanks @orf !

It looks like this might also solve for #105

Had you considered adding a test case for this, so that the behavior can be expressed and verified that this fixes the issue?

@miketheman miketheman self-assigned this Jan 21, 2022
@miketheman

Copy link
Copy Markdown
Owner

Thanks!
Closed by #109 - I've added you as a co-author on that change.

@miketheman miketheman closed this Jan 22, 2022
@miketheman miketheman added this to the 0.5.1 milestone Jan 23, 2022
@miketheman

Copy link
Copy Markdown
Owner

Released in 0.5.1

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

Successfully merging this pull request may close these issues.

2 participants