old_contents: from armstrong.dev.tests.utils.base import ArmstrongTestCase
  from django.contrib.auth.models import User
  import random
  
  def generate_random_user():
      r = random.randint(10000, 20000)
      return User.objects.create(username="random-user-%d" % r,
              first_name="Some", last_name="Random User %d" % r)
  
  
  def generate_random_staff_users(n=2):
      orig_users = generate_random_users(n)
      users = User.objects.filter(pk__in=[a.id for a in orig_users])
      users.update(is_staff=True)
      return [a for a in users]
  
  
  class generate_random_staff_usersTestCase(ArmstrongTestCase):
      def test_returns_2_users_by_default(self):
          self.assertEqual(len(generate_random_staff_users()), 2)
  
      def test_returns_n_users(self):
          r = random.randint(1, 5)
          self.assertEqual(len(generate_random_staff_users(r)), r)
  
      def test_all_users_are_staff(self):
          users = generate_random_staff_users()
          for user in users:
              self.assertTrue(user.is_staff)
  
  
  def generate_random_users(n=2):
      return [generate_random_user() for i in range(n)]
new_contents: import random
  try:
      from django.contrib.auth import get_user_model
  except ImportError:  # Django < 1.5
      from django.contrib.auth.models import User
  else:
      User = get_user_model()
  
  
  def generate_random_users(count, **extra_fields):
      """Generator to create ``count`` number of unique random users"""
  
      num = random.randint(1000, 2000)
      while count > 0:
          fields = dict(
              username="random-user-%d" % num,
              first_name="Some",
              last_name="Random User %d" % num,
              **extra_fields)
          yield User.objects.create(**fields)
          num += random.randint(2, 20)
          count -= 1
  
subject: Fix and simplify `generate_random_users()`. Randomization wasn't guaranteed and I've seen it break with `IntegrityError: column username is not unique`.