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

debugging py_test targets with pytest main "hangs" #6824

Open
rajukrishnamurthy opened this issue Oct 2, 2024 · 6 comments · Fixed by #6847
Open

debugging py_test targets with pytest main "hangs" #6824

rajukrishnamurthy opened this issue Oct 2, 2024 · 6 comments · Fixed by #6847
Assignees
Labels
awaiting-user-response Awaiting response from author on PRs product: IntelliJ IntelliJ plugin product: PyCharm PyCharm plugin type: bug

Comments

@rajukrishnamurthy
Copy link

Description of the bug:

pytest targets executed with pytest.main() seems to hang, but appears to be running stat() every file in the filesystem. The debugging session doesn't ever start because there are inevitably unreadable files with throws errors.

Which category does this issue belong to?

Intellij, PyCharm

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

a minimal repo can be found here

If you debug the unit_test target, I am able to set successfully debug. However, if you try to debug the pytest_test target, it "hangs" on with the folllowing:

import sys; print('Python %s on %s' % (sys.version, sys.platform))
/usr/bin/python3 "/Users/rkrishnamurthy/Library/Application Support/JetBrains/IntelliJIdea2024.2/plugins/python-ce/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 51013 --file /private/var/tmp/_bazel_rkrishnamurthy/5303facb39f6d1f7ffd509576224e2f0/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/bin/demo/python/idea_debug/py/py_test
Connected to pydev debugger (build 242.23339.11)
============================= test session starts ==============================
platform darwin -- Python 3.9.18, pytest-7.0.1, pluggy-1.0.0
rootdir: /

if you pause/restart the debugging session a few times, there are repeated calls to Path.stat() in lib/python3.9/pathlib.py

Which Intellij IDE are you using? Please provide the specific version.

IDEA ultimate 2024.2.3

What programming languages and tools are you using? Please provide specific versions.

python 3.9 toolchain

What Bazel plugin version are you using?

2024.09.10.0.1-api-version-242

Have you found anything relevant by searching the web?

There is an ongoing slack thread, however, the ability to debug py_test targets is new, so I suspect people haven't run into this yet.

Any other information, logs, or outputs that you want to share?

No response

@rajukrishnamurthy rajukrishnamurthy added awaiting-maintainer Awaiting review from Bazel team on issues type: bug labels Oct 2, 2024
@github-actions github-actions bot added product: IntelliJ IntelliJ plugin product: PyCharm PyCharm plugin labels Oct 2, 2024
@agluszak agluszak self-assigned this Oct 4, 2024
@agluszak
Copy link
Collaborator

agluszak commented Oct 4, 2024

Hey @rajukrishnamurthy, could you verify if #6847 fixes the issue for you?

@agluszak agluszak added awaiting-user-response Awaiting response from author on PRs and removed awaiting-maintainer Awaiting review from Bazel team on issues labels Oct 5, 2024
@rajukrishnamurthy
Copy link
Author

@agluszak I pulled down master built and installed the plugin and am getting the same behavior with the repo I referenced above.

@tpasternak
Copy link
Collaborator

Oh, just found we've already received this report in #5146

@agluszak
Copy link
Collaborator

@agluszak I pulled down master built and installed the plugin and am getting the same behavior with the repo I referenced above.

It's not merged yet, so you need to build branch agluszak/fix-6824

@tpasternak
Copy link
Collaborator

@rajukrishnamurthy I have merged that, you can try master branch now

@tpasternak tpasternak reopened this Oct 10, 2024
@rajukrishnamurthy
Copy link
Author

Apologies, I didn't look at that closely enough. Okay, with the fix in place it is no longer scanning the entire filesystem, however it doesn't seem to actually run the test. I've noticed a couple of things:

  1. when pytest.main() is called in my stripped down example, I can trace to pytest_cmdline_main return NO_TESTS_COLLECTED. Perhaps my main is incorrect?
  2. We override the py_test macro where we set environment variables args that we use to pass to pytest.main(). It seems to bypass that entirely and use the py_test from rules_python. I've added an example with an override of py_test defined here. This is probably a separate problem, but I imagine many people do this.

In both cases, bazel test runs the tests correctly.

I'm happy to continue to be a tester and I will try to be more timely in my response.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting response from author on PRs product: IntelliJ IntelliJ plugin product: PyCharm PyCharm plugin type: bug
Projects
Status: Untriaged
Development

Successfully merging a pull request may close this issue.

4 participants