import factory
import factory.django
import factory.fuzzy

from tracpro.test.factory_utils import FuzzyEmail


__all__ = ['User']


class User(factory.django.DjangoModelFactory):
    username = factory.fuzzy.FuzzyText()
    email = FuzzyEmail()

    class Meta:
        model = "auth.User"

    @factory.post_generation
    def password(self, create, extracted, **kwargs):
        password = extracted or "password"
        self.set_password(password)
        if create:
            self.save()

import factory
import factory.django
import factory.fuzzy

from tracpro.test.factory_utils import FuzzyEmail


__all__ = ['User']


class User(factory.django.DjangoModelFactory):
    username = factory.fuzzy.FuzzyText()
    email = FuzzyEmail()

    class Meta:
        model = "auth.User"

    @factory.post_generation
    def password(self, create, extracted, **kwargs):
        password = extracted or self.username
        self.set_password(password)
        if create:
            self.save()

Use username as password default
Use username as password default

For compatibility with TracProTest.login()

  import factory
  import factory.django
  import factory.fuzzy
  
  from tracpro.test.factory_utils import FuzzyEmail
  
  
  __all__ = ['User']
  
  
  class User(factory.django.DjangoModelFactory):
      username = factory.fuzzy.FuzzyText()
      email = FuzzyEmail()
  
      class Meta:
          model = "auth.User"
  
      @factory.post_generation
      def password(self, create, extracted, **kwargs):
-         password = extracted or "password"
+         password = extracted or self.username
          self.set_password(password)
          if create:
              self.save()
  
Use username as password default
## Code Before:
import factory
import factory.django
import factory.fuzzy

from tracpro.test.factory_utils import FuzzyEmail


__all__ = ['User']


class User(factory.django.DjangoModelFactory):
    username = factory.fuzzy.FuzzyText()
    email = FuzzyEmail()

    class Meta:
        model = "auth.User"

    @factory.post_generation
    def password(self, create, extracted, **kwargs):
        password = extracted or "password"
        self.set_password(password)
        if create:
            self.save()

## Instruction:
Use username as password default
## Code After:
import factory
import factory.django
import factory.fuzzy

from tracpro.test.factory_utils import FuzzyEmail


__all__ = ['User']


class User(factory.django.DjangoModelFactory):
    username = factory.fuzzy.FuzzyText()
    email = FuzzyEmail()

    class Meta:
        model = "auth.User"

    @factory.post_generation
    def password(self, create, extracted, **kwargs):
        password = extracted or self.username
        self.set_password(password)
        if create:
            self.save()
