In organising tests in PyTest
, I have seen that the test methods can be defined within a test class, like so:
class TestBasicEquality:
def test_a_equals_b(self):
assert 'a' == 'b'
If we want to write a test (test_client
) that has to use a PyTest fixture client
we do something like this:
def test_client(client):
# assert client.something == something
But how can we organise the test_client
within a test class? I have tried using @pytest.mark.usefixtures(client)
as a decorator for the test class with no success.
Can someone show how and/or point to a guide/documentation for me to understand?
And perhaps a question hidden behind all this: when should we (or shouldn't) put pytest tests within a class? (only now starting to learn PyTest..) ?