m0_68488384 2022-10-13 20:25 采纳率: 100%
浏览 28
已结题

Pycharm 运行pytest.main() 方法加入参数”-n=3“ 时运行提示下面的错误,无法解决,当前python版本是2.7,用过3.6,3.9都不行.在终端是可以运行成功的

问题遇到的现象和发生背景

Pycharm 运行pytest.main() 方法加入参数”-n=3“ 时运行提示下面的错误,无法解决,当前python版本是2.7,用过3.6,3.9都不行.在终端是可以运行成功的

用代码块功能插入代码,请勿粘贴截图
import os
import pytest
import requests


class Test_Yield_S:
    a = 100

    @pytest.fixture(scope='function')
    def start(self):
        print('11111111111111111')
        yield Test_Yield_S.a
        # return Test_Yield_S.a

    def test_end(self, start):
        rep = requests.get('https://www.baidu.com/')
        print('https://www.baidu.com/'+rep.encoding+'')

    # @pytest.mark.lixiangjiang
    def test_bilibili(self):
        rep = requests.get('https://www.bilibili.com/')
        print('https://www.bilibili.com/'+rep.encoding+'')

    # def setup(self):
    #     print('^^^^^^^^^^^^^^^^')
    #
    # def teardown(self):
    #     print('VVVVVVV123VVVV')


if __name__ == '__main__':
    pytest.main(['-vs', '-n=3'])

运行结果及报错内容

C:\Users\Administrator\anaconda3\envs\python=2.7\python.exe C:\Users\Administrator\PycharmProjects\pythonProject3\test_yield_sample.py
usage: test_yield_sample.py [options] [file_or_dir] [file_or_dir] [...]
test_yield_sample.py: error: unrecognized arguments: -n=3
inifile: None
rootdir: C:\Users\Administrator\PycharmProjects\pythonProject3

我的解答思路和尝试过的方法

升级python或者降级python都不行

我想要达到的结果

--html=./**.html 也不可以使用

  • 写回答

1条回答 默认 最新

  • 亖夕 新星创作者: python技术领域 2022-10-13 21:03
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月22日
  • 已采纳回答 10月14日
  • 创建了问题 10月13日