diff --git a/.travis.yml b/.travis.yml index 4161577b..24088e7c 100644 --- a/.travis.yml +++ b/.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: diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..6405cffa --- /dev/null +++ b/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. diff --git a/inquirer/questions.py b/inquirer/questions.py index 0b808b51..f0f7ca71 100644 --- a/inquirer/questions.py +++ b/inquirer/questions.py @@ -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): diff --git a/inquirer/render/__init__.py b/inquirer/render/__init__.py index db70e884..b5ea4c63 100644 --- a/inquirer/render/__init__.py +++ b/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 diff --git a/inquirer/render/console/base.py b/inquirer/render/console/base.py index 9653549f..cda19a53 100644 --- a/inquirer/render/console/base.py +++ b/inquirer/render/console/base.py @@ -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, diff --git a/requirements-dev.txt b/requirements-dev.txt index d4cb01e8..a2c7fff7 100644 --- a/requirements-dev.txt +++ b/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 diff --git a/requirements.txt b/requirements.txt index 8e7d1284..ed37ac46 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -blessings >= 1.6 -readchar >= 2.0.0 +blessings==1.7 +readchar==2.0.1 diff --git a/tests/acceptance/test_checkbox.py b/tests/acceptance/test_checkbox.py index 3cc42685..fd84a7ba 100644 --- a/tests/acceptance/test_checkbox.py +++ b/tests/acceptance/test_checkbox.py @@ -10,7 +10,7 @@ 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) @@ -18,7 +18,7 @@ def test_select_the_third(self): 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) @@ -28,7 +28,7 @@ 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 ) @@ -36,7 +36,7 @@ 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) @@ -44,7 +44,7 @@ def test_select_with_arrows(self): self.sut.send(key.RIGHT) self.sut.send(key.ENTER) self.sut.expect( - "{'interests': \['Computers', 'Books', 'Science'\]}.*", + "{'interests': \['Computers', 'Books', 'Science'\]}.*", # noqa timeout=1 ) @@ -52,7 +52,7 @@ 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): @@ -60,7 +60,7 @@ def test_select_last(self): self.sut.send(key.SPACE) self.sut.send(key.ENTER) self.sut.expect( - "{'interests': \['Computers', 'Books', 'History'\]}.*", + "{'interests': \['Computers', 'Books', 'History'\]}.*", # noqa timeout=1 ) diff --git a/tests/integration/console_render/test_text.py b/tests/integration/console_render/test_text.py index 84e00cac..ff1cae21 100644 --- a/tests/integration/console_render/test_text.py +++ b/tests/integration/console_render/test_text.py @@ -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, @@ -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)