title: Take a snapshot of the contents of a Windows console
body: <p>I have a program that produces colored output on the console, and I want to write a test ensuring the output is correct.</p>
  
  <p>On Unix-like systems this is done using <a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors" rel="nofollow noreferrer">ANSI escape codes</a>, so capturing the output stream is enough to check the rendered colors.</p>
  
  <p>On Windows, I'm using <a href="https://pypi.python.org/pypi/colorama" rel="nofollow noreferrer">colorama</a> to translate the ANSI codes to Win32 API calls. However, I'd still like to ensure the right colors are being produced.</p>
  
  <p>How do I programmatically capture the contents of a Windows console to compare it to the expected output?</p>
  
  <p>Any format is OK as long as the content doesn't spuriously change - HTML, an image, PDF, etc.</p>
  
  <p>The test in question needs to run on AppVeyor, so it probably does not have a graphical environment ready.</p>