awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.15k stars 770 forks source link

Fix integrations tests to work with prompt_toolkit 1.0.4 #135

Closed joguSD closed 7 years ago

joguSD commented 7 years ago

prompt_toolkit updated to version 1.0.4 which adds an assertion that the input/output given to a CommandLineInterface be a TTY. This assertion happens at object instantiation which affects the way we do some of our integration tests.

We currently have some tests in integration\test_keys.py and integration\test_selectmenu.py that instantiate CLIs and simulate key presses to them by calling feed and process_keys. This is used to test that key bindings are properly registered and have the correct results on the state of the CLI. However, the CLI's run method is not called, meaning that the actual input and output streams seem to not be used. This is what allowed the tests to function previously. Now that there are assertions to verify that the input and output are TTYs at instantiation the tests fail immediately. This can be fixed by passing Input and Output objects that don't rely on stdin and stdout.

This is what the fix would like. For test_keys.py we would next to change the AWSShell to pass a pluggable input and output when it creates it's CLI.

@JordonPhillips @jamesls

JordonPhillips commented 7 years ago
--    .-""-.
   ) (     )
  (   )   (
     /     )
    (_    _)                     0_,-.__
      (_  )_                     |_.-._/
       (    )                    |_--..\
        (__)                     |__--_/
     |''   ``\                   |
     |        \                  |      /b.
     |         \  ,,,---===?A`\  |  ,==y'
   ___,,,,,---==""\        |M] \ | ;|\ |>
           _   _   \   ___,|H,,---==""""bno,
    o  O  (_) (_)   \ /          _     AWAW/
                     /         _(+)_  dMM/
      \@_,,,,,,---=="   \      \\|//  MW/
--''''"                         ===  d/
                                    //
                                    ,'__________________________
   \    \    \     \               ,/~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         _____    ,'  ~~~   .-""-.~~~~~~  .-""-.
      .-""-.           ///==---   /`-._ ..-'      -.__..-'
            `-.__..-' =====\\\\\\ V/  .---\.
                      ~~~~~~~~~~~~, _',--/_.\  .-""-.
                            .-""-.___` --  \|         -.__..-