I need to pass class members as parameters to pytest.mark.parametrize
.
The following code does not work (I've used simple members strings, but in my case they are complex and constructed):
import pytest
class TestSmth(object):
def setup_class(cls):
cls.a = "a"
cls.b = "b"
cls.c = "c"
@pytest.mark.parametrize("test_input,expected", [
(self.a, "a"),
(self.b, "b"),
(self.c, "c")
])
def test_members(test_input, expected):
assert test_input == expected
Is it possible to achieve such result? Or something similar?