title: Testing Click application prompting with multiple inputs
body: <p>I've written a small command line application using Click and Python, which I am now trying to write tests for (mainly for the purpose of learning how to test Click apps so I can move on to testing the one I'm actually developing). </p>
  
  <p>Here's a function I'm trying to test:</p>
  
  <pre><code>@click.group()
  def main():
      pass    
  
  @main.command()
  @click.option('--folder', '-f', prompt="What do you want to name the folder? (No spaces please)")
  def create_folder(folder):
      while True:
          if " " in folder:
              click.echo("Please enter a name with no spaces.")
              folder = click.prompt("What do you want to name the folder?", type=str)
          if folder in os.listdir():
              click.echo("This folder already exists.")
              folder = click.prompt("Please choose a different name for the folder")
          else:
              break
  
      os.mkdir(folder)
      click.echo("Your folder has been created!")
  </code></pre>
  
  <p>I'm trying to test this using the built in testing from Click (<a href="http://click.pocoo.org/6/testing/" rel="nofollow noreferrer">http://click.pocoo.org/6/testing/</a> and <a href="http://click.pocoo.org/6/api/#testing" rel="nofollow noreferrer">http://click.pocoo.org/6/api/#testing</a> for more details) as well as pytest. This works well in the case where I test an acceptable folder name (ie. one that does not have spaces and that does not already exist). See below:</p>
  
  <pre><code>import clicky # the module we're testing
  import os
  from click.testing import CliRunner
  import click
  import pytest
  input sys
  
  runner = CliRunner()
  folder = "myfolder"
  folder_not = "my folder"
  
  question_create = "What do you want to name the folder? (No spaces please): "
  echoed = "\nYour folder has been created!\n"
  
  def test_create_folder():
      with runner.isolated_filesystem():
          result = runner.invoke(clicky.create_folder, input=folder)
          assert folder in os.listdir()
          assert result.output == question_create + folder + echoed
  </code></pre>
  
  <p>I now want to test this function in the case where I provide a folder name that's not allowed, such as one with spaces, and then after the prompt telling me I can't have spaces, I will provide an acceptable folder name. However, I cannot figure out how to make <code>click.runner</code> accept more than one input value, and that's the only way I can think to make that work. I'm also open to using unittest mocking, but I'm not sure how to integrate that into the way Click does tests, which other than this problem has worked wonderfully so far. Here's my attempt with multiple inputs:</p>
  
  <pre><code>def test_create_folder_not():
      with runner.isolated_filesystem():
          result = runner.invoke(clicky.create_folder, input=[folder_not, folder]) # here i try to provide more than one input
          assert result.output == question_create + folder_not + "\nPlease enter a name with no spaces.\n" + "What do you want to name the folder?: " + folder + echoed
  </code></pre>
  
  <p>I tried to provide  multiple inputs by putting them in a list, like what I've seen done with mocking, but I get this error:</p>
  
  <pre><code>'list' object has no attribute 'encode'
  </code></pre>
  
  <p>Any thoughts on this would be greatly appreciated!</p>