diff --git a/examples/located.py b/examples/located.py new file mode 100644 index 00000000..f45ef8d0 --- /dev/null +++ b/examples/located.py @@ -0,0 +1,19 @@ +# encoding: utf-8 +import os +import sys +import re +sys.path.append(os.path.realpath('.')) +from pprint import pprint + +import inquirer + +LangQuestion = [ + inquirer.List('lang', + message="Select Language", + choices=['English', 'Français', 'Deutsche', 'Español'], + ), +] + +answers = inquirer.prompt(LangQuestion) + +pprint(answers) diff --git a/inquirer/__init__.py b/inquirer/__init__.py index 023dcde3..af5e4115 100644 --- a/inquirer/__init__.py +++ b/inquirer/__init__.py @@ -1,6 +1,6 @@ from __future__ import print_function -__version__ = '2.2.0' +__version__ = '2.3.0' try: from .prompt import prompt diff --git a/inquirer/render/console/__init__.py b/inquirer/render/console/__init__.py index 48b4897d..a3ede23d 100644 --- a/inquirer/render/console/__init__.py +++ b/inquirer/render/console/__init__.py @@ -69,6 +69,8 @@ def _print_status_bar(self, render): def _print_options(self, render): for message, symbol, color in render.get_options(): + if hasattr(message, 'decode'): # python 2 + message = message.decode('utf-8') self.print_line(' {color}{s} {m}{t.normal}', m=message, color=color, s=symbol) diff --git a/inquirer/render/console/_list.py b/inquirer/render/console/_list.py index ba46287f..a0510ace 100644 --- a/inquirer/render/console/_list.py +++ b/inquirer/render/console/_list.py @@ -45,7 +45,6 @@ def process_input(self, pressed): value = self.question.choices[self.current] raise errors.EndOfInput(getattr(value, 'value', value)) - raise errors.EndOfInput(self.question.choices[self.current]) if pressed == key.CTRL_C: raise KeyboardInterrupt() diff --git a/tests/unit/test_question.py b/tests/unit/test_question.py index 61cbd1fb..fa025dc8 100644 --- a/tests/unit/test_question.py +++ b/tests/unit/test_question.py @@ -1,3 +1,5 @@ +# encoding: utf-8 + import os import shutil import tempfile @@ -176,6 +178,14 @@ def test_factory_list_type(self): self.assertIsInstance(q, questions.List) self.assertEquals(name, q.name) + def test_factory_located_list_type(self): + name = 'ñçÑÇ' + q = questions.question_factory('list', name) + + self.assertEquals('list', q.kind) + self.assertIsInstance(q, questions.List) + self.assertEquals(name, q.name) + def test_factory_checkbox_type(self): name = 'foo' q = questions.question_factory('checkbox', name)