title: Py.test: How to parametrize when some values should return an error
body: <p>I'm new at testing and wondering if it is possible to parametrize values that should return a value, and others that should return an error to a single test. </p>
  
  <p>Let's say I have a simple function <code>divide_hundred_by(x)</code>, defined as follows:</p>
  
  <pre class="lang-py prettyprint-override"><code>def divide_hundred_by(x):
      if x == 0: 
           raise ZeroDivisionError('You cannot divide by zero') 
      return 100/x
  </code></pre>
  
  <p>Now, I'd like to test this function for a couple of values for <em>x</em> and parametrize this test. I found that I can use: </p>
  
  <pre class="lang-py prettyprint-override"><code>import pytest
  
  @pytest.mark.parametrize('value, expected',
                           [
                               (10, 10),
                               (-2, -50),
                               (0.5, 200)
                           ]
                           )
  def test_divide_hundred_by(value, expected):
  
      with pytest.raises(ZeroDivisionError): 
          divide_hundred_by(0)
  
      assert divide_hundred_by(value) == expected
  </code></pre>
  
  <p>But this ensures that if the warning-part fails, the entire test fails for all values, which is not what I'd like. </p>
  
  <p>I'm wondering if it is possible to write something of the form:</p>
  
  <pre class="lang-py prettyprint-override"><code>@pytest.mark.parametrize('value, expected',
                           [
                               (10, 10),
                               (-2, -50),
                               (0.5, 200),
                               (0, "ZeroDivisionError") 
                           ]
                           )
  def test_divide_hundred_by(value, expected):
      assert divide_hundred_by(value) == expected
  </code></pre>
  
  <p>such that the test will pass for the other parameters. I cannot find anything online on the matter.  </p>