Uploaded Test files
This commit is contained in:
parent
f584ad9d97
commit
2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions
2
venv/Lib/site-packages/winpty/tests/__init__.py
Normal file
2
venv/Lib/site-packages/winpty/tests/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""winpty module tests."""
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
61
venv/Lib/site-packages/winpty/tests/test_cywinpty.py
Normal file
61
venv/Lib/site-packages/winpty/tests/test_cywinpty.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Cywinpty tests."""
|
||||
|
||||
# yapf: disable
|
||||
|
||||
# Third party imports
|
||||
from winpty.cywinpty import Agent
|
||||
from winpty.winpty_wrapper import PY2
|
||||
from winpty.ptyprocess import which
|
||||
import pytest
|
||||
|
||||
|
||||
# yapf: disable
|
||||
|
||||
CMD = which('cmd')
|
||||
if PY2:
|
||||
CMD = unicode(CMD) # noqa
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def agent_fixture():
|
||||
def _agent_factory(cols, rows):
|
||||
agent = Agent(cols, rows)
|
||||
return agent
|
||||
return _agent_factory
|
||||
|
||||
|
||||
def test_agent_spawn(agent_fixture):
|
||||
agent = agent_fixture(80, 25)
|
||||
succ = agent.spawn(CMD)
|
||||
assert succ
|
||||
del agent
|
||||
|
||||
|
||||
def test_agent_spawn_fail(agent_fixture):
|
||||
agent = agent_fixture(80, 25)
|
||||
try:
|
||||
agent.spawn(CMD)
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
def test_agent_spawn_size_fail(agent_fixture):
|
||||
try:
|
||||
agent_fixture(80, -25)
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
def test_agent_resize(agent_fixture):
|
||||
agent = agent_fixture(80, 25)
|
||||
agent.set_size(80, 70)
|
||||
del agent
|
||||
|
||||
|
||||
def test_agent_resize_fail(agent_fixture):
|
||||
agent = agent_fixture(80, 25)
|
||||
try:
|
||||
agent.set_size(-80, 70)
|
||||
except RuntimeError:
|
||||
pass
|
150
venv/Lib/site-packages/winpty/tests/test_ptyprocess.py
Normal file
150
venv/Lib/site-packages/winpty/tests/test_ptyprocess.py
Normal file
|
@ -0,0 +1,150 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""winpty wrapper tests."""
|
||||
|
||||
# yapf: disable
|
||||
|
||||
# Standard library imports
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
|
||||
# Third party imports
|
||||
from flaky import flaky
|
||||
from winpty.ptyprocess import PtyProcess
|
||||
import pytest
|
||||
|
||||
|
||||
# yapf: enable
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def pty_fixture():
|
||||
def _pty_factory(cmd=None, env=None):
|
||||
cmd = cmd or 'cmd'
|
||||
return PtyProcess.spawn(cmd, env=env)
|
||||
return _pty_factory
|
||||
|
||||
|
||||
@flaky(max_runs=4, min_passes=1)
|
||||
def test_read(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
loc = os.getcwd()
|
||||
data = ''
|
||||
while loc not in data:
|
||||
data += pty.read()
|
||||
pty.terminate()
|
||||
|
||||
|
||||
def test_write(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
|
||||
text = u'Eggs, ham and spam ünicode'
|
||||
pty.write(text)
|
||||
|
||||
data = ''
|
||||
while text not in data:
|
||||
data += pty.read()
|
||||
pty.terminate()
|
||||
|
||||
|
||||
def test_isalive(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
pty.write('exit\r\n')
|
||||
|
||||
text = 'exit'
|
||||
data = ''
|
||||
while text not in data:
|
||||
data += pty.read()
|
||||
|
||||
while 1:
|
||||
try:
|
||||
pty.read()
|
||||
except EOFError:
|
||||
break
|
||||
|
||||
assert not pty.isalive()
|
||||
pty.terminate()
|
||||
|
||||
|
||||
def test_readline(pty_fixture):
|
||||
env = os.environ.copy()
|
||||
env['foo'] = 'bar'
|
||||
pty = pty_fixture(env=env)
|
||||
pty.write('echo %foo%\r\n')
|
||||
|
||||
while 'bar' not in pty.readline():
|
||||
pass
|
||||
|
||||
pty.terminate()
|
||||
|
||||
|
||||
def test_close(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
pty.close()
|
||||
assert not pty.isalive()
|
||||
|
||||
|
||||
def test_flush(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
pty.flush()
|
||||
pty.terminate()
|
||||
|
||||
|
||||
def test_intr(pty_fixture):
|
||||
pty = pty_fixture(cmd=[sys.executable, 'import time; time.sleep(10)'])
|
||||
pty.sendintr()
|
||||
assert pty.wait() != 0
|
||||
|
||||
|
||||
def test_send_control(pty_fixture):
|
||||
pty = pty_fixture(cmd=[sys.executable, 'import time; time.sleep(10)'])
|
||||
pty.sendcontrol('d')
|
||||
assert pty.wait() != 0
|
||||
|
||||
|
||||
def test_send_eof(pty_fixture):
|
||||
cat = pty_fixture('cat')
|
||||
cat.sendeof()
|
||||
assert cat.wait() == 0
|
||||
|
||||
|
||||
def test_isatty(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
assert pty.isatty()
|
||||
pty.terminate()
|
||||
assert not pty.isatty()
|
||||
|
||||
|
||||
def test_wait(pty_fixture):
|
||||
pty = pty_fixture(cmd=[sys.executable, '--version'])
|
||||
assert pty.wait() == 0
|
||||
|
||||
|
||||
def test_exit_status(pty_fixture):
|
||||
pty = pty_fixture(cmd=[sys.executable])
|
||||
pty.write('import sys;sys.exit(1)\r\n')
|
||||
pty.wait()
|
||||
assert pty.exitstatus == 1
|
||||
|
||||
|
||||
def test_kill(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
pty.kill(signal.SIGTERM)
|
||||
assert not pty.isalive()
|
||||
assert pty.exitstatus == signal.SIGTERM
|
||||
|
||||
|
||||
def test_getwinsize(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
assert pty.getwinsize() == (24, 80)
|
||||
pty.terminate()
|
||||
|
||||
|
||||
def test_setwinsize(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
pty.setwinsize(50, 110)
|
||||
assert pty.getwinsize() == (50, 110)
|
||||
pty.terminate()
|
||||
|
||||
pty = PtyProcess.spawn('cmd', dimensions=(60, 120))
|
||||
assert pty.getwinsize() == (60, 120)
|
||||
pty.terminate()
|
78
venv/Lib/site-packages/winpty/tests/test_winpty_wrapper.py
Normal file
78
venv/Lib/site-packages/winpty/tests/test_winpty_wrapper.py
Normal file
|
@ -0,0 +1,78 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""winpty wrapper tests."""
|
||||
|
||||
# yapf: disable
|
||||
|
||||
# Standard library imports
|
||||
import os
|
||||
|
||||
# Third party imports
|
||||
from flaky import flaky
|
||||
from winpty.winpty_wrapper import PTY, PY2
|
||||
from winpty.ptyprocess import which
|
||||
import pytest
|
||||
|
||||
|
||||
# yapf: enable
|
||||
|
||||
CMD = which('cmd')
|
||||
if PY2:
|
||||
CMD = unicode(CMD) # noqa
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def pty_fixture():
|
||||
def _pty_factory():
|
||||
pty = PTY(80, 25)
|
||||
pty.spawn(CMD)
|
||||
return pty
|
||||
return _pty_factory
|
||||
|
||||
|
||||
@flaky(max_runs=4, min_passes=1)
|
||||
def test_read(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
loc = os.getcwd()
|
||||
line = ''
|
||||
while loc not in line:
|
||||
line += pty.read().decode('utf-8')
|
||||
assert loc in line
|
||||
pty.close()
|
||||
del pty
|
||||
|
||||
|
||||
def test_write(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
line = pty.read()
|
||||
while len(line) < 10:
|
||||
line = pty.read()
|
||||
|
||||
text = u'Eggs, ham and spam ünicode'
|
||||
pty.write(text)
|
||||
|
||||
line = u''
|
||||
while text not in line:
|
||||
line += pty.read().decode('utf-8')
|
||||
|
||||
assert text in line
|
||||
|
||||
pty.close()
|
||||
del pty
|
||||
|
||||
|
||||
def test_isalive(pty_fixture):
|
||||
pty = pty_fixture()
|
||||
pty.write(u'exit\r\n')
|
||||
|
||||
text = u'exit'
|
||||
line = u''
|
||||
while text not in line:
|
||||
line += pty.read().decode('utf-8')
|
||||
|
||||
while pty.isalive():
|
||||
pty.read()
|
||||
continue
|
||||
|
||||
assert not pty.isalive()
|
||||
pty.close()
|
||||
del pty
|
Loading…
Add table
Add a link
Reference in a new issue