@staticmethod
    def create_test_user():
        user_model = get_user_model()
        # Create a user
        user_data = dict()
        user_data[user_model.USERNAME_FIELD] = 'test@email.com'
        user_data['password'] = 'password'

        for field in user_model.REQUIRED_FIELDS:
            user_data[field] = field

        return user_model.objects.create_superuser(**user_data)
Override this method to return an instance of your custom user model
dataset/ETHPy150Open torchbox/wagtail/wagtail/tests/utils.py/WagtailTestUtils.create_test_user