You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyCharm中运行pytest出现空测试套件问题求助

Troubleshooting PyCharm 2017.3.2 pytest Execution Issue

Let's break down and fix the problem you're facing when running pytest in PyCharm. First, let's recap your setup to make sure we're aligned:

Your Setup Details

  • Test file path: C:\Temp\agents_automation_2\x_tests.py
  • Test code:
import pytest
def test_mytest():
    assert False
  • Partial run output:
C:\Python36-32\python.exe "C:\Program Files\JetBrains\PyCharm 2017.3.2\helpers\pycharm\_jb_pytest_runner.py" --path C:/Temp/agents_automation_2
Launching py.test with arguments C:/Temp/agents_automation_2 in C:\Temp\agents_automation_2...

It looks like PyCharm is initiating the pytest runner, but not completing the test execution or showing results. Here are the most likely fixes, ordered by simplicity:


1. Run the Test File Directly (Not Just the Directory)

Instead of running the entire agents_automation_2 directory, try targeting the specific test file directly:

  • Right-click on x_tests.py in PyCharm's project explorer
  • Select Run 'pytest in x_tests.py'
    This tells PyCharm to create a dedicated configuration for that file, eliminating ambiguity about which tests to execute.

2. Verify Your PyTest Run Configuration

If the above doesn't work, double-check your run configuration settings:

  1. Click the run dropdown in the top-right of PyCharm → Select Edit Configurations...
  2. If you don't have an existing pytest config, click the + button and choose pytest
  3. For the Target field, select Script path and browse to your x_tests.py file
  4. Confirm the Python interpreter is set to C:\Python36-32\python.exe (the environment you intend to use)
  5. Save the configuration and run it again

3. Ensure pytest is Installed in Your Target Interpreter

It's possible the Python interpreter PyCharm is using doesn't have pytest installed. Let's fix that:

  1. Open PyCharm's built-in Terminal
  2. Run this command to install a PyCharm 2017.3.2-compatible pytest version:
    C:\Python36-32\python.exe -m pip install pytest==4.6.11
    
    (Newer pytest versions aren't fully supported by older PyCharm releases like 2017.3.2)
  3. Test if pytest works outside PyCharm first by running:
    cd C:\Temp\agents_automation_2
    C:\Python36-32\python.exe -m pytest x_tests.py -v
    
    You should see the assertion failure output here. If this works, the issue was simply missing pytest in the selected interpreter.

4. Enable the PyTest Plugin in PyCharm

Older PyCharm versions sometimes disable plugins by default:

  1. Go to File → Settings → Plugins
  2. Search for pytest in the plugin list
  3. Make sure the checkbox next to it is checked
  4. Restart PyCharm to apply the change

内容的提问来源于stack exchange,提问作者David Fliguer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:21:55