Skip to content

#7124: Fix --doctest-modules crashing when __main__.py is present #8949

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

Merged

Conversation

symonk
Copy link
Member

@symonk symonk commented Jul 27, 2021

Hi, hope you are all doing well. Been a bit busy as of lately but I am hoping to start contributing again, here is an issue outlined in:

#7124

whereby when --doctest-modules was being passed, ImportError on __main__.py was raised, causing a crash. I have added a special case for __main__.py here, similarly to setup.py, would welcome any feed back on this approach or if you can guide me to another one if this is incorrect.

  • adds __main__.py specific checks for the doctest plugin collect_item hook implementation
  • unit / integration tests

@@ -0,0 +1,2 @@
def test_this_is_ignored():
assert True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do wonder, should a doctest in this file be considered?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after reading the details, its a clear nope, as its typically unguarded

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank 👍

@symonk symonk merged commit 6d6bc97 into pytest-dev:main Jul 27, 2021
@symonk symonk deleted the handle-dunder-main-py-in-docstring-modules branch July 27, 2021 21:50
RonnyPfannschmidt pushed a commit to RonnyPfannschmidt/pytest that referenced this pull request Oct 1, 2021
…is present (pytest-dev#8949)

* Fix ``--doctest-modules`` crashing when ``__main__.py`` is present
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.

None yet

2 participants