测试人社区

【求助】pytest 相关

请教一个问题:
已经安装了pytest 和 allure,但是在pycharm终端输入pytest --alluredir 文件名 执行的时候提示command not found:pytest,接着输入allure serve 也是同样的提示:command not found :allure 。请问有什么方式可以解决此问题?

需要先确认一下pycharm终端有没有启用虚拟环境,然后需要确认一下pytest与allure安装的位置,如果终端前面是有(venv)的话就是虚拟环境,需要在虚拟环境中安装pytest与allure

谢谢您的解答,我这边用的是本地环境,本地环境有什么使用限制吗?

下载了allure-pytest???,是需要下载这个包才可以执行pytest --alluredir 相关命令的

下载了的,这个加上allure加上pytest 都下载了的

环境变量配置了吗,环境变量配置后有尝试重启吗

直接输入allure之后是有下面这些反应的,具体如下:

 ~ % allure
Usage: allure [options] [command] [command options]
  Options:
    --help
      Print commandline help.
    -q, --quiet
      Switch on the quiet mode.
      Default: false
    -v, --verbose
      Switch on the verbose mode.
      Default: false
    --version
      Print commandline version.
      Default: false
  Commands:
    generate      Generate the report
      Usage: generate [options] The directories with allure results
        Options:
          -c, --clean
            Clean Allure report directory before generating a new one.
            Default: false
          --config
            Allure commandline config path. If specified overrides values from 
            --profile and --configDirectory.
          --configDirectory
            Allure commandline configurations directory. By default uses 
            ALLURE_HOME directory.
          --profile
            Allure commandline configuration profile.
          -o, --report-dir, --output
            The directory to generate Allure report into.
            Default: allure-report

    serve      Serve the report
      Usage: serve [options] The directories with allure results
        Options:
          --config
            Allure commandline config path. If specified overrides values from 
            --profile and --configDirectory.
          --configDirectory
            Allure commandline configurations directory. By default uses 
            ALLURE_HOME directory.
          -h, --host
            This host will be used to start web server for the report.
          -p, --port
            This port will be used to start web server for the report.
            Default: 0
          --profile
            Allure commandline configuration profile.

    open      Open generated report
      Usage: open [options] The report directory
        Options:
          -h, --host
            This host will be used to start web server for the report.
          -p, --port
            This port will be used to start web server for the report.
            Default: 0

    plugin      Generate the report
      Usage: plugin [options]
        Options:
          --config
            Allure commandline config path. If specified overrides values from 
            --profile and --configDirectory.
          --configDirectory
            Allure commandline configurations directory. By default uses 
            ALLURE_HOME directory.
          --profile
            Allure commandline configuration profile.


这应该证明allure是配置了的对吧?
Mac用homebrew安装的也需要配置环境变量吗?

参考这个