Skip to content

Commit

Permalink
[MRG] #10 merged to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedek Racz committed Nov 4, 2019
2 parents 9ce8421 + b69c3c6 commit 3484a98
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 75 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ child.sendline('exit')

For more information see [examples](./examples) folder.

## Code Clean up!

Wexpect works only on Windows platforms. There are handy tools for other platforms. Therefore I will
remove any non-windows code. If you see following warning in your console please contact me to
prevent the removal of that function.

```
################################## WARNING ##################################
<some func> is deprecated, and will be removed soon.
Please contact me and report it at github.com/raczben/wexpect if you use it.
################################## WARNING ##################################
```

---
## What is it?

Expand Down
20 changes: 14 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ environment:
testpypipw:
secure: CcyBI8e/2LdIT2aYIytTAgR4795DNBDM/ztsz1kqZYYOeNc3zlJWLdYWrnjCHn5W6/ZcAHrsxCdCMHvtr6PIVgBRpl2RR3fk2jKTzKqJJsLW871q30BsE0kws32f1IiqfjVtLn8BUC91IJ2xBBXtOYktf1tCMi3zJMSF9+MIOQKIu298bIRnD1Lc+4lzcSZJOn4I7dOMdzlcCMRqhtO58TGwR/hD+22FHjyWVB8nLL18AO+XXS9lHSOUrH6rD5NYvVFZD68oV/RrCGAjRmfMnw==


build: off

install:
Expand Down Expand Up @@ -39,9 +38,18 @@ after_test:
# Create source distribution.
- python -m setup sdist

# Upload to test pypi
- twine upload -r testpypi dist\\wexpect*.tar.gz
# Upload to pypi.
# More precisely. The master and release builds will be uploaded to pypi. Test branch will be
# uploaded to test-pypi the test builds.
# See more at https://stackoverflow.com/a/39155147/2506522

# Upload to offitial pypi
- twine upload -r pypi dist\\wexpect*.tar.gz

- IF %APPVEYOR_REPO_BRANCH%==master (
twine upload -r pypi dist\\wexpect*.tar.gz
)
- IF %APPVEYOR_REPO_TAG%==true (
twine upload -r pypi dist\\wexpect*.tar.gz
)
- IF %APPVEYOR_REPO_BRANCH%==test (
twine upload -r testpypi dist\\wexpect*.tar.gz
)

4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Settings for https://codecov.io/gh/raczben/wexpect/

ignore:
- tests/* # ignore folders and all its contents
36 changes: 0 additions & 36 deletions examples/cmd.py

This file was deleted.

15 changes: 15 additions & 0 deletions tests/lines_printer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'''
This is is a very basic stdio handler script. This is used by python.py example.
'''

import time

# Read an integer from the user:
print('Give a small integer: ', end='')
num = input()

# Wait the given time
for i in range(int(num)):
print('waiter ' + str(i))
time.sleep(0.2)
print('Bye!')
4 changes: 4 additions & 0 deletions tests/test_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def test_constructor (self):
p2 = wexpect.spawn('uname', ['-m', '-n', '-p', '-r', '-s', '-v'])
p2.expect(wexpect.EOF)
self.assertEqual(p1.before, p2.before)
self.assertEqual(str(p1).splitlines()[1:9], str(p2).splitlines()[1:9])

run_result = wexpect.run('uname -m -n -p -r -s -v')
self.assertEqual(run_result, p2.before)

def test_named_parameters (self):
'''This tests that named parameters work.
Expand Down
83 changes: 83 additions & 0 deletions tests/test_readline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/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 sys
import os
import unittest
from . import PexpectTestCase

here = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, here)

print(wexpect.__version__)

# With quotes (C:\Program Files\Python37\python.exe needs quotes)
python_executable = '"' + sys.executable + '" '
child_script = here + '\\lines_printer.py'

class ReadLineTestCase(PexpectTestCase.PexpectTestCase):
def testReadline(self):
fooPath = python_executable + ' ' + child_script
prompt = ': '
num = 5

# Start the child process
p = wexpect.spawn(fooPath)
# Wait for prompt
p.expect(prompt)
p.sendline(str(num))
p.expect('Bye!\r\n')
expected_lines = p.before.splitlines(True) # Keep the line end
expected_lines += [p.match.group()]

# Start the child process
p = wexpect.spawn(fooPath)
# Wait for prompt
p.expect(prompt)

p.sendline(str(num))
for i in range(num +2): # +1 the line of sendline +1: Bye
line = p.readline()
self.assertEqual(expected_lines[i], line)

# Start the child process
p = wexpect.spawn(fooPath)
# Wait for prompt
p.expect(prompt)

p.sendline(str(num))
readlines_lines = p.readlines()
self.assertEqual(expected_lines, readlines_lines)


if __name__ == '__main__':
unittest.main()

suite = unittest.makeSuite(ReadLineTestCase,'test')

0 comments on commit 3484a98

Please sign in to comment.