How to use readchar - 10 common examples

To help you get started, we’ve selected a few readchar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github magmax / python-inquirer / tests / integration / test_console_render.py View on Github external
def test_cannot_move_beyond_upper_limit(self):
        stdin = (key.UP
                 + key.UP
                 + key.UP
                 + key.SPACE
                 + key.ENTER)
        message = 'Foo message'
        variable = 'Bar variable'
        choices = ['foo', 'bar', 'bazz']

        sys.stdin = StringIO(stdin)
        question = questions.Checkbox(variable, message, choices=choices)

        sut = ConsoleRender(key_generator=fake_key_generator)
        result = sut.render(question)

        self.assertEqual(['foo'], result)
github magmax / python-inquirer / tests / integration / console_render / test_checkbox.py View on Github external
def test_cannot_move_beyond_upper_limit(self):
        stdin = helper.event_factory(
            key.UP,
            key.UP,
            key.UP,
            key.SPACE,
            key.ENTER,)
        message = 'Foo message'
        variable = 'Bar variable'
        choices = ['foo', 'bar', 'bazz']

        question = questions.Checkbox(variable, message, choices=choices)

        sut = ConsoleRender(event_generator=stdin)
        result = sut.render(question)

        self.assertEqual(['foo'], result)
github magmax / python-inquirer / tests / acceptance / test_password.py View on Github external
def test_backspace_limit(self):
        self.sut.expect("What's.*", timeout=1)
        self.sut.send('a')
        self.sut.send(key.BACKSPACE)
        self.sut.send(key.BACKSPACE)
        self.sut.send('b')
        self.sut.send(key.ENTER)
        self.sut.expect("{'password': 'b'}", timeout=1)
github magmax / python-inquirer / tests / acceptance / test_password.py View on Github external
def test_backspace_limit(self):
        self.sut.expect("What's.*", timeout=1)
        self.sut.send('a')
        self.sut.send(key.BACKSPACE)
        self.sut.send(key.BACKSPACE)
        self.sut.send('b')
        self.sut.send(key.ENTER)
        self.sut.expect("{'password': 'b'}", timeout=1)
github magmax / python-inquirer / tests / integration / console_render / test_confirm.py View on Github external
def test_yes_as_default(self):
        stdin = helper.event_factory(key.ENTER)
        message = 'Foo message'
        variable = 'Bar variable'
        expected = True

        question = questions.Confirm(variable,
                                     message=message,
                                     default=True)

        sut = ConsoleRender(event_generator=stdin)
        result = sut.render(question)

        self.assertEqual(expected, result)
        self.assertInStdout(message)
        self.assertInStdout('(Y/n)')
github magmax / python-inquirer / tests / acceptance / test_checkbox.py View on Github external
def test_unselect_with_arrows(self):
        self.sut.send(key.DOWN)
        self.sut.send(key.LEFT)
        self.sut.send(key.ENTER)
        self.sut.expect("{'interests': \['Computers'\]}.*", timeout=1)  # noqa
github magmax / python-inquirer / tests / integration / test_console_render.py View on Github external
def test_can_move(self):
        stdin = (key.DOWN
                 + key.DOWN
                 + key.UP
                 + key.SPACE
                 + key.ENTER)
        message = 'Foo message'
        variable = 'Bar variable'
        choices = ['foo', 'bar', 'bazz']

        sys.stdin = StringIO(stdin)
        question = questions.Checkbox(variable, message, choices=choices)

        sut = ConsoleRender(key_generator=fake_key_generator)
        result = sut.render(question)

        self.assertEqual(['bar'], result)
github magmax / python-inquirer / tests / integration / console_render / test_list.py View on Github external
def test_all_choices_are_shown(self):
        stdin = helper.event_factory(key.ENTER)
        message = 'Foo message'
        variable = 'Bar variable'
        choices = ['foo', 'bar', 'bazz']

        question = questions.List(variable, message, choices=choices)

        sut = ConsoleRender(event_generator=stdin)
        sut.render(question)

        self.assertInStdout(message)
        for choice in choices:
            self.assertInStdout(choice)
github magmax / python-inquirer / tests / acceptance / test_checkbox.py View on Github external
def test_default_input(self):
        self.sut.send(key.ENTER)
        self.sut.expect("{'interests': \['Computers', 'Books'\]}.*", timeout=1)  # noqa
github magmax / python-inquirer / tests / integration / console_render / test_confirm.py View on Github external
def test_no_as_default(self):
        stdin = helper.event_factory(key.ENTER)
        message = 'Foo message'
        variable = 'Bar variable'
        expected = False

        question = questions.Confirm(variable,
                                     message=message)

        sut = ConsoleRender(event_generator=stdin)
        result = sut.render(question)

        self.assertEqual(expected, result)
        self.assertInStdout(message)
        self.assertInStdout('(y/N)')

readchar

Library to easily read single chars and key strokes

MIT
Latest version published 2 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages