-1

Having variable like list1=[1,2,3,4,5] and another list2=[2,3,4,5,6] I want to make assertions about each item in first list like

class MyTest(unittest.TestCase):
     for num in list1:
         self.assertIn(num, list2)

And I need unique name for each test. I've something like this in nose or py.test package, but can not find where exactly.

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
Munky munk
  • 41
  • 4
  • 2
    So, what is your question? What have you done so far and where do you need help? – n2o May 27 '15 at 12:52

1 Answers1

0

Using parametrization: http://pytest.org/latest/parametrize.html

import pytest

list1 = [1, 2, 3, 4, 5]
list2 = [2, 3, 4, 5, 6]

@pytest.mark.parametrize('num', list1)
def test_contains(num):
    assert num in list2
flub
  • 5,953
  • 27
  • 24