def mock_inputs(inputs):
 def inner(test_func):
  def wrapped(*args):
   class mock_getpass:
    @staticmethod
    def getpass(prompt='Password: ', stream=None):
     if (not PY3):
      assert isinstance(prompt, binary_type)
     return inputs[u'password']
   def mock_input(prompt):
    prompt = str(prompt)
    assert (str(u'__proxy__') not in prompt)
    response = u''
    for (key, val) in inputs.items():
     if (force_str(key) in prompt.lower()):
      response = val
      break
    return response
   old_getpass = createsuperuser.getpass
   old_input = createsuperuser.input
   createsuperuser.getpass = mock_getpass
   createsuperuser.input = mock_input
   try:
    test_func(*args)
   finally:
    createsuperuser.getpass = old_getpass
    createsuperuser.input = old_input
  return wrapped
 return inner

def mock_inputs ( inputs ) : def inner ( test_func ) : def wrapped ( * args ) : class mock_getpass : @ staticmethod def getpass ( prompt = 'Password: ' , stream = None ) : if ( not PY3 ) : assert isinstance ( prompt , binary_type ) return inputs [ u'password' ] def mock_input ( prompt ) : prompt = str ( prompt ) assert ( str ( u'__proxy__' ) not in prompt ) response = u'' for ( key , val ) in inputs . items ( ) : if ( force_str ( key ) in prompt . lower ( ) ) : response = val break return response old_getpass = createsuperuser . getpass old_input = createsuperuser . input createsuperuser . getpass = mock_getpass createsuperuser . input = mock_input try : test_func ( * args ) finally : createsuperuser . getpass = old_getpass createsuperuser . input = old_input return wrapped return inner
decorator to temporarily replace input/getpass to allow interactive createsuperuser .