コード例 #1
0
ファイル: test_cli.py プロジェクト: RyanBallantyne/plumbum
 def test_ask(self):
     with captured_stdout("\n") as stream:
         self.assertTrue(ask("Do you like cats?", default = True))
     self.assertEqual(stream.getvalue(), "Do you like cats? [Y/n] ")
     with captured_stdout("\nyes") as stream:
         self.assertTrue(ask("Do you like cats?"))
     self.assertEqual(stream.getvalue(), "Do you like cats? (y/n) Invalid response, please try again\nDo you like cats? (y/n) ")
コード例 #2
0
ファイル: test_terminal.py プロジェクト: AndydeCleyre/plumbum
    def test_ask(self, capsys):
        with send_stdin("\n"):
            assert ask("Do you like cats?", default = True)
        assert capsys.readouterr()[0] == "Do you like cats? [Y/n] "

        with send_stdin("\nyes"):
            assert ask("Do you like cats?")
        assert capsys.readouterr()[0] == "Do you like cats? (y/n) Invalid response, please try again\nDo you like cats? (y/n) "
コード例 #3
0
ファイル: main.py プロジェクト: Clear-ICT/voodoo
 def __init__(self, *args, **kwargs):
     super(VoodooSub, self).__init__(*args, **kwargs)
     if args and args[0] == 'voodoo new':
         return
     config_path = '.'.join([self.parent.env, DOCKER_COMPOSE_PATH])
     if self.parent.env == 'dev':
         self.config_path = config_path
     elif local.path(config_path).is_file():
         self.config_path = config_path
     elif local.path(DOCKER_COMPOSE_PATH).is_file():
         self.config_path = DOCKER_COMPOSE_PATH
     else:
         raise_error(
             "There is not %s.%s or %s file, please add one"
             % (self.parent.env, DOCKER_COMPOSE_PATH, DOCKER_COMPOSE_PATH))
     self.main_service = self._get_main_service()
     if self.parent.env == 'dev':
         if not local.path(self.config_path).isfile():
             generate = ask(
                 "There is not dev.docker-compose.yml file.\n"
                 "Do you want to generate one automatically",
                 default=True)
             if generate:
                 self.run_hook(GenerateDevComposeFile)
             else:
                 raise_error("No dev.docker-compose.yml file, abort!")
     self.compose = compose['-f', self.config_path]