"Desired Capabilities must be a dictionary" 将字典传递给参数化方法时出错

"Desired Capabilities must be a dictionary" error when passing dict into parametrized method

我正在使用 Appium 和 pytest 测试移动应用程序。当我试图通过参数化的 pytest 标记传递字典列表时出现以下错误。

 WebDriverException: Message: Desired Capabilities must be a dictionary

当我不使用 @pytest.mark.parametrize() 并将所需功能作为字典直接传递给 webdriver.Remote 时它工作正常。

为了更好地理解,我稍微简化了我的代码:

class TestQATestProject(object): 
  def get_all(self):
      return [
          {'platformName': 'Android'},
          {'platformName': 'Android'}
      ]


  @pytest.mark.parametrize('desired_caps', get_all())
  def setup_method(self, desired_caps):
      self.driver = webdriver.Remote('http://localhost:4723/wd/hub', 
  desired_caps)
      self.driver.implicitly_wait(5000)

[UPD] 我发现 @pytest.mark.parametrize 对于 setup_method 不能正常工作。那么还有另一种方法可以 运行 测试不同的配置吗?

@pytest.mark.unit 帮我做个交易