首页 > 解决方案 > 得到“ValueError:选项名称 {'--alluredir'} 已添加”

问题描述

再会。有这样的代码:

import pytest
import requests
import json
from jsonschema import validate


class DogTest:

    def test_status_code(self):
        res = requests.get("https://dog.ceo/api/breeds/list/all")
        assert res.status_code == 200

    def test_list_all_breeds_app_j(self):
        res = requests.get("https://dog.ceo/api/breeds/list/all")
        assert res.headers["Content-Type"] == "application/json"

    def test_list_all_breeds_schema(self):
        res = requests.get("https://dog.ceo/api/breeds/list/all")

        schema = {
            "type": "object",
            "properties": {
                    "message": {
                    "type": "object",
                    "additionalProperties": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
          },
                    "status": {
                    "type": "string"
                }
            },
            "required": ["message", "status"]
        }
        validate(instance=res.json(), schema=schema)

    @pytest.mark.parametrize("single_breed", ["zhoochka"])
    def test_breed_not_exists(self, single_breed):
        res = requests.get(f"https://dog.ceo/api/breed/{single_breed}/images",
                       params={'single_breed': single_breed})
        response_body = res.json()
        assert response_body["message"] == "Breed not found (master breed does not exist)"
        assert response_body["status"] == "error"
        assert response_body["code"] == 404

    @pytest.mark.parametrize('dog, subdog', [("bulldog", ['boston', 'english', 'french']),
                                         ("mountain", ['bernese', 'swiss'])])
    def test_some_subbreed(self, dog, subdog):
        res = requests.get(f"https://dog.ceo/api/breed/{dog}/list",
                      params={'dog': dog})
        response_body = res.json()
        assert response_body['message'] == subdog
        assert response_body['status'] == 'success'

以前,代码正在执行。但是现在,在我allure-pytest为另一个项目安装插件后,出现以下错误: 在此处输入图像描述

据我了解,pytest正在尝试conftest.py从使用 的项目中读取allure-pytest,但该项目位于其自己的目录中,该目录不是此代码的根目录。如何修复此错误?

标签: python-3.xpytest

解决方案


推荐阅读