gregmuellegger/django-autofixture

UserFixture is not in REGISTRY

johnbuluba opened this issue · 1 comments

I wanted to create a user with predefined password for a test so i did this:

    import autofixture
    class Test(TestCase):
        def test(self):
            user = autofixture.create_one(User, username='test', password='test')

This raises an exception : TypeError: init() got an unexpected keyword argument 'username'

To fix this i had to import autofixture.autofixures like this:

    import autofixture
    import autofixture.autofixtures
    class Test(TestCase):
        def test(self):
            user = autofixture.create_one(User, username='test', password='test')

which worked

Yes, the registry is not loaded by default. You can run the autofixture.autodiscover() function to trigger the automatic loading of pre-defined autofixtures. It works similiar to Django's django.contrib.admin.autodiscover().