1

I'm testing mobile applications using Appium and pytest. Following error appears when I'm trying to pass a list of dictionaries through the parametrized pytest mark.

 WebDriverException: Message: Desired Capabilities must be a dictionary

It works fine when I'm not using @pytest.mark.parametrize() and pass desired capabilities directly as a dictionary to webdriver.Remote.

I've simplified my code a little bit for better understanding:

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] I've figured out that @pytest.mark.parametrize doesn't work properly for setup_method. So is there another way to run tests on different configs?

si13n
  • 15
  • 7
  • 1
    I don't think there's a self, because the decorator is outside any method – Silly Freak Apr 04 '19 at 06:57
  • ok, my bad, lets say there will be some kinda devices.get.all(). its not a point – si13n Apr 04 '19 at 07:01
  • would it work to just `print(desired_caps)` and compare it to what you expect instead of the `webdriver` code? Because I'm not convinced that your code as it is now would work: `get_all` is still an instance method of `TestQATestProject`. – Silly Freak Apr 04 '19 at 20:10
  • marks in @pytest.mark.parameterize is deperecated since pytest 4.0 which might be causing the issue. Please go through the given url if you are using latest pytest: https://docs.pytest.org/en/latest/deprecations.html – SRM21 Apr 06 '19 at 11:27
  • thanks a lot. problem is solved with @pytest.mark.unit – si13n Apr 16 '19 at 11:57

1 Answers1

0

@pytest.mark.unit makes a deal for me

si13n
  • 15
  • 7