I am trying to use a pytest fixture (scope=module) in a class skipif decorator, but I am getting an error saying the fixture is not defined. Is this possible?
conftest.py has a fixture with module scope called 'target' that returns a CurrentTarget object. The CurrentTarget object has a function isCommandSupported. test_mytest.py has a class Test_MyTestClass that contains a dozen test functions. I want to skip all the tests in Test_MyTestClass based on if the fixture target.isCommandSupported so I decorate Test_MyTestClass with skipif like:
@pytest.mark.skipif(not target.isCommandSupprted('commandA), reason=command not supported')
class Test_MyTestClass:
...
I get this error: NameError: name 'target' is not defined
If I try:
@pytest.mark.skipif(not pytest.config.getvalue('tgt').isCommandSupprted('commandA), reason=command not supported')
class Test_MyTestClass:
...
I get this error: AttributeError: 'function' object has no attribute 'isCommandSupprted'