From c47974e799c37ba7d5db7518df71a3e297061ee1 Mon Sep 17 00:00:00 2001 From: Benedek Racz Date: Mon, 23 Sep 2019 15:58:02 +0200 Subject: [PATCH] [CLN] Readme; [ADD] interact testcase, to improve coverage --- README.md | 27 +++++-------------- tests/test_interact.py | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 tests/test_interact.py diff --git a/README.md b/README.md index 6078024..36ac63a 100644 --- a/README.md +++ b/README.md @@ -79,29 +79,14 @@ To run test, enter into the folder of the wexpect's repo then: `python -m unittest` -### Release +### Deploy + +The deployment itself is automated and done by [appveyor](https://ci.appveyor.com/project/raczben/wexpect). +See `after_test` section in [appveyor.yml](appveyor.yml) for more details. The wexpect uses [pbr](https://docs.openstack.org/pbr/latest/) for managing releasing procedures. -*Pre-release tasks:* - - - First of all be sure that your modification is good, by running the tests. - - Commit your modification. - - Create a test build `python -m setup sdist` - - Upload the test `twine upload -r testpypi dist\wexpect-.tar.gz` (You must install twine first.) - - create virtualenv `virtualenv wexpectPy` - - Activate the virtualenv `.\Scripts\activate.bat` - - Install the test build `python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple wexpect` - - run `python -c "import wexpect;print(wexpect.__version__)"` - -*Release tasks:* - - - Tag your commit (see the version tag format.) - - Run `python -m setup sdist` - - Upload the archive using: `twine upload dist/wexpect-.tar.gz` - - create virtualenv `virtualenv wexpectPy2` - - Activate the virtualenv `.\Scripts\activate.bat` - - Install the test build `python -m pip install wexpect` - - run `python -c "import wexpect;print(wexpect.__version__)"` +The versioning is handled by the pbr. The *"master-version"* is the git tag. Pbr derives the package +version from the git tags. ## Basic behaviour diff --git a/tests/test_interact.py b/tests/test_interact.py new file mode 100644 index 0000000..7b0e73e --- /dev/null +++ b/tests/test_interact.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +''' +MIT License + +Copyright (c) 2008 Noah Spurrier, Richard Holden, Marco Molteni, Kimberley Burchett, Robert Stone, +Hartmut Goebel, Chad Schroeder, Erick Tryzelaar, Dave Kirby, Ids vander Molen, George Todd, +Noel Taylor, Nicolas D. Cesar, Alexander Gattin, Geoffrey Marshall, Francisco Lourenco, Glen Mabey, +Karthik Gurusamy, Fernando Perez, Corey Minyard, Jon Cohen, Guillaume Chazarain, Andrew Ryan, +Nick Craig-Wood, Andrew Stone, Jorgen Grahn, Benedek Racz + +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. +''' + +import wexpect +import time +import unittest +from . import PexpectTestCase + +class InteractTestCase(PexpectTestCase.PexpectTestCase): + def testPath(self): + # Path of cmd executable: + cmd_exe = 'cmd' + cmdPrompt = '>' + + # Start the child process + p = wexpect.spawn(cmd_exe) + + # Wait for prompt + p.expect(cmdPrompt) + + p.interact() + time.sleep(1) + + # Send a command + p.sendline('echo hello') + p.expect(cmdPrompt) + + self.assertEqual('hello', p.before.splitlines()[1]) + +if __name__ == '__main__': + unittest.main() + +suite = unittest.makeSuite(InteractTestCase,'test')