I have one test-case with one fixture:
@pytest.fixture
def user(test_client):
return User.objects.first()
@pytest.mark.parametrize('content', ['nice post',])
def test_post(test_client, user, content):
reponse = test_client.post(
'/api/v1.0/posts',
json={
'content': content,
'author': user,
},
follow_redirects=True
)
assert reponse.status_code == 200
But I want in addition to testing against some User object, to test against None (I expect test to fail for None). I thought I could do something like:
@pytest.fixture(params=[True, False])
def User_or_null(test_client, request):
if request.param:
return User.objects.first()
else:
return None
But I do not think this will allow me to mark the test case with pytest.mark.xfail for None value? Any Ideas?