Reputation: 67
my code
@pytest.mark.parametrize(
("username", "password", "message"),
(
("", "", b"Username is required."),
("a", "", b"Password is required."),
("test", "test", b"already registered"),
),
)
def test_register_validate_input(client, username, password, message):
response = client.post(
"/register", data={"username": username, "password": password}
)
assert message in response.data
def test_register_delete_input(client, username, password, message):
response = client.delete(
"/register", data={"username": username, "password": password}
)
assert message in response.data
if i run python -m pytest i am getting
fixture 'username' not found
however if i remove the block for
def test_register_delete_input(client, username, password, message):
response = client.delete(
"/register", data={"username": username, "password": password}
)
assert message in response.data
the test works
Upvotes: 0
Views: 36
Reputation: 71
You could copypaste the @pytest.mark.parametrize(...)
block from the first test to the second test, because it only parametrizes the first test but not the second.
Alternatively, do what this user recommended here - getting fixture from parameterized for multiple tests
It could be combined, in theory; but, since you're testing two different actions (post
in first one and delete
in the second one), I'd say it's better to keep these two tests separate.
Upvotes: 1