Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set custom UserFactory for tp pytest fixture #125

Open
mblayman opened this issue May 21, 2020 · 0 comments
Open

Set custom UserFactory for tp pytest fixture #125

mblayman opened this issue May 21, 2020 · 0 comments

Comments

@mblayman
Copy link

Hi, y'all! I set up pytest on my Django project this evening. I was/am hoping to replace my use of the unittest-derived TestCase defined in this project with the tp fixture made available by pytest plugin.

Judging by plugin.py, it looks like it's not possible to set a custom UserFactory for the fixture like you can for the TestCase.

It would be nice to be able to define this for the tp fixture too. Without this ability, tp.make_user is limited to the User.objects.create_user call on https://github.com/revsys/django-test-plus/blob/master/test_plus/test.py#L266.

One possible thought to fix this would be to expose a pytest configuration option that would set a module path to the UserFactory (e.g., myapp.factories.UserFactory) and load that class onto the t.user_factory attribute when the tp fixture creates the TestCase.

Thanks for the great project. I really enjoy the extensions that test plus provides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant