I defined UserFactory
class in tests/factories.py
as shown below following the doc. *I use pytest-django and pytest-factoryboy in Django:
# "tests/factories.py"
import factory
from django.contrib.auth.models import User
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = User
And, I defined test_user_instance()
with @pytest.mark.parametrize() to test 4 users as shown below:
# "tests/test_ex1.py"
import pytest
from django.contrib.auth.models import User
@pytest.mark.parametrize(
"username, email",
{
("John", "test@test.com"), # Here
("John", "test@test.com"), # Here
("John", "test@test.com"), # Here
("John", "test@test.com") # Here
}
)
def test_user_instance(
db, user_factory, username, email
):
user_factory(
username=username,
email=email
)
item = User.objects.all().count()
assert item == True
But, only one user was tested as shown below:
$ pytest -q
. [100%]
1 passed in 0.65s
So, how can I test 4 tests?