Skip to content

Commit

Permalink
Merge pull request #62 from AuHau/fix/#61-Type_conversion
Browse files Browse the repository at this point in the history
Fix/#61 type conversion
  • Loading branch information
AuHau committed Mar 5, 2019
2 parents 669854a + 904c15f commit 11e6fb0
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 40 deletions.
112 changes: 93 additions & 19 deletions .travis.yml
@@ -1,25 +1,99 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"
- "pypy"
- "pypy3"
stages:
- name: lint
- name: test
- name: deploy-pip
if: tag IS present
# - name: deploy-mkdocs
# if: tag IS present
- name: deploy-release
if: tag IS present

install:
- pip install -r requirements-dev.txt -r requirements.txt
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install unittest2 mock; fi
- python setup.py install

script:
- make flakes
- make run_integration_tests
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then make run_acceptance_tests; fi
jobs:
include:
- stage: lint
name: "Flakes"
language: python
python:
- "3.7"
dist: xenial
sudo: true
install:
- pip install flake8
script:
- make flakes

after_success:
- make coveralls
- stage: test
name: "Tests"
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8-dev"
- "pypy"
- "pypy3"
dist: xenial
sudo: true
install:
- pip install -r requirements-dev.txt
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install unittest2 mock; fi
- python setup.py install
script:
- make run_integration_tests
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then make run_acceptance_tests; fi
after_success:
- make coveralls

- stage: deploy-pip
name: "Publish to PyPi"
language: python
python: '3.7'
dist: xenial
sudo: true
script:
- pip install -r test-requirements.txt
deploy:
provider: pypi
user: AuHau-deploy
distributions: sdist bdist_wheel
skip_existing: true
on:
tags: true
repo: magmax/python-inquirer
password:
secure: "U3TCm2jfVDh1jlsLUMNT+3gORy7QselNgXmLaAAVeFsmOjyxDNfQ0jfo7vVuv5/lMvDEJCe/ODDnAudM0YGKXB40viz1fMUddjK5y4PrSIbNG+EZMyLYh6AJt4J6wQuINeyUBiqDM+uV9iRscsEAv/m3Hx05UACPO3RQHRSHwkE="

# - stage: deploy-mkdocs
# name: "Publish documentation"
# language: python
# python: '3.7'
# dist: xenial
# sudo: true
# install:
# - pip install -r test-requirements.txt
# script:
# - git config user.name "Adam Uhlir";
# - git config user.email "hello@adam-uhlir.me";
# - git remote add gh-token "https://${GH_TOKEN}@github.com/magmax/python-inquirer.git";
# - git fetch gh-token && git fetch gh-token gh-pages:gh-pages;
# - mkdocs gh-deploy -v --clean --remote-name gh-token;

- stage: deploy-release
name: "Create release"
language: python
python: '3.7'
dist: xenial
sudo: true
script: echo 'Lets do it!'
deploy:
provider: releases
api_key: ${GH_TOKEN}
on:
tags: true
repo: magmax/python-inquirer

notifications:
email:
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Miguel Ángel García

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 6 additions & 1 deletion inquirer/questions.py
Expand Up @@ -139,8 +139,13 @@ def _solve(self, prop, *args, **kwargs):
class Text(Question):
kind = 'text'

def __init__(self, name, message='', default=None, **kwargs):
super(Text, self).__init__(name, message=message,
default=str(default) if default
else default, **kwargs)

class Password(Question):

class Password(Text):
kind = 'password'

def __init__(self, name, echo='*', **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion inquirer/render/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from .console import ConsoleRender
try:
from .ncourses import CoursesRender
from .ncourses import CoursesRender # noqa
except ImportError:
# ncourses will not be available
pass
Expand Down
2 changes: 1 addition & 1 deletion inquirer/render/console/base.py
Expand Up @@ -27,7 +27,7 @@ def get_options(self):
return []

def read_input(self):
raise NotImplemented('Abstract')
raise NotImplementedError('Abstract')

def handle_validation_error(self, error):
return '"{e}" is not a valid {q}.'.format(e=error.value,
Expand Down
16 changes: 9 additions & 7 deletions requirements-dev.txt
@@ -1,11 +1,13 @@
flake8 >= 3.4.1
pexpect >= 4.2.1
-r requirements.txt

pytest >= 3.2.1
pytest-cov >= 2.5.1
pytest-xdist >= 1.10
nosexcover >= 1.0.10
flake8==3.7.7
pexpect==4.6.0

python-coveralls >= 2.9.1
pytest==4.3.0
pytest-cov==2.6.1
pytest-xdist==1.26.1
nosexcover==1.0.11

python-coveralls==2.9.1

wheel >= 0.24.0
4 changes: 2 additions & 2 deletions requirements.txt
@@ -1,2 +1,2 @@
blessings >= 1.6
readchar >= 2.0.0
blessings==1.7
readchar==2.0.1
14 changes: 7 additions & 7 deletions tests/acceptance/test_checkbox.py
Expand Up @@ -10,15 +10,15 @@ def setUp(self):

def test_default_input(self):
self.sut.send(key.ENTER)
self.sut.expect("{'interests': \['Computers', 'Books'\]}.*", timeout=1)
self.sut.expect("{'interests': \['Computers', 'Books'\]}.*", timeout=1) # noqa

def test_select_the_third(self):
self.sut.send(key.DOWN)
self.sut.send(key.DOWN)
self.sut.send(key.SPACE)
self.sut.send(key.ENTER)
self.sut.expect(
"{'interests': \['Computers', 'Books', 'Science'\]}.*", timeout=1)
"{'interests': \['Computers', 'Books', 'Science'\]}.*", timeout=1) # noqa

def test_select_one_more(self):
self.sut.send(key.DOWN)
Expand All @@ -28,39 +28,39 @@ def test_select_one_more(self):
self.sut.send(key.SPACE)
self.sut.send(key.ENTER)
self.sut.expect(
"{'interests': \['Computers', 'Books', 'Science', 'Nature'\]}.*",
"{'interests': \['Computers', 'Books', 'Science', 'Nature'\]}.*", # noqa
timeout=1
)

def test_unselect(self):
self.sut.send(key.SPACE)
self.sut.send(key.SPACE)
self.sut.send(key.ENTER)
self.sut.expect("{'interests': \['Books', 'Computers'\]}.*", timeout=1)
self.sut.expect("{'interests': \['Books', 'Computers'\]}.*", timeout=1) # noqa

def test_select_with_arrows(self):
self.sut.send(key.DOWN)
self.sut.send(key.DOWN)
self.sut.send(key.RIGHT)
self.sut.send(key.ENTER)
self.sut.expect(
"{'interests': \['Computers', 'Books', 'Science'\]}.*",
"{'interests': \['Computers', 'Books', 'Science'\]}.*", # noqa
timeout=1
)

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)
self.sut.expect("{'interests': \['Computers'\]}.*", timeout=1) # noqa

def test_select_last(self):
for i in range(10):
self.sut.send(key.DOWN)
self.sut.send(key.SPACE)
self.sut.send(key.ENTER)
self.sut.expect(
"{'interests': \['Computers', 'Books', 'History'\]}.*",
"{'interests': \['Computers', 'Books', 'History'\]}.*", # noqa
timeout=1
)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/console_render/test_text.py
Expand Up @@ -34,7 +34,7 @@ def test_ignore_true_should_return(self):
stdin = 'This is a foo message'
message = 'Foo message'
variable = 'Bar variable'
expected = object()
expected = ''

question = questions.Text(variable,
ignore=True,
Expand All @@ -59,7 +59,7 @@ def test_validation_fails(self):
expected = '9999'

question = questions.Text(variable,
validate=lambda _, x: re.match('\d+', x),
validate=lambda _, x: re.match(r'\d+', x),
message=message)

sut = ConsoleRender(event_generator=stdin)
Expand Down

0 comments on commit 11e6fb0

Please sign in to comment.