Skip to content

Commit

Permalink
Merge pull request #125 from andfoy/python38
Browse files Browse the repository at this point in the history
PR: Add support for Python 3.8
  • Loading branch information
andfoy authored Nov 26, 2019
2 parents f4461cd + b37fc6e commit c7e1f1e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 42 deletions.
15 changes: 12 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ environment:
APPVEYOR_RDP_PASSWORD: "dcca4c4863E30d56c2e0dda6327370b3#"

matrix:
- PYTHON_VERSION: "3.8"
PYTHON_ARCH: "32"
ARCH: "x86"
- PYTHON_VERSION: "3.7"
PYTHON_ARCH: "32"
ARCH: "x86"
Expand All @@ -33,6 +36,10 @@ environment:
PYTHON_ARCH: "32"
ARCH: "x86"
platform: "x86"
- PYTHON_VERSION: "3.8"
PYTHON_ARCH: "64"
ARCH: "amd64"
platform: "x64"
- PYTHON_VERSION: "3.7"
PYTHON_ARCH: "64"
ARCH: "amd64"
Expand All @@ -55,13 +62,15 @@ install:
- "set PATH=%PATH:\"=%"
- "git clone git://github.com/astropy/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
# - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
# Use test conda environment
- "activate test"
# - "conda init"
# - "conda activate base"
- "conda activate test"
# - CALL "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat" %ARCH%
- "conda install -q --file requirements.txt"
- "pip install -q twine codecov"
- "%CMD_IN_ENV% python setup.py build_ext -i --compiler=mingw32"
- "%CMD_IN_ENV% powershell appveyor/build.ps1"

# Not a .NET project, we build in the install step instead
build: false
Expand Down
12 changes: 12 additions & 0 deletions appveyor/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

if($env:PYTHON_VERSION -match "2.7") {
if ($env:ARCH -match "amd64") {
# We need to pass the -DMS_WIN64 flag in order to prevent a
# compilation error on Python 2.7 (x64)
python setup.py build_ext -i --compiler=mingw32 -DMS_WIN64
}
else {
python setup.py build_ext -i --compiler=mingw32
}
}
else { python setup.py build_ext -i --compiler=mingw32 }
2 changes: 1 addition & 1 deletion appveyor/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if ($env:APPVEYOR_REPO_TAG -match "true") {

if ($env:ARCH -match "amd64") {
copy-item $LIB_GCC_64 $FOLDER
if($env:PYTHON_VERSION -match "3.6") {
if($env:PYTHON_VERSION -match "3.7") {
python setup.py sdist
}
}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ m2w64-toolchain
libpython

# Test requirements
pytest<4
pytest<5
coveralls
flaky
pytest-cov
18 changes: 10 additions & 8 deletions winpty/tests/test_cywinpty.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,42 @@


@pytest.fixture(scope='module')
def agent_fixture(cols, rows):
agent = Agent(cols, rows)
return agent
def agent_fixture():
def _agent_factory(cols, rows):
agent = Agent(cols, rows)
return agent
return _agent_factory


def test_agent_spawn():
def test_agent_spawn(agent_fixture):
agent = agent_fixture(80, 25)
succ = agent.spawn(CMD)
assert succ
del agent


def test_agent_spawn_fail():
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():
def test_agent_spawn_size_fail(agent_fixture):
try:
agent_fixture(80, -25)
except RuntimeError:
pass


def test_agent_resize():
def test_agent_resize(agent_fixture):
agent = agent_fixture(80, 25)
agent.set_size(80, 70)
del agent


def test_agent_resize_fail():
def test_agent_resize_fail(agent_fixture):
agent = agent_fixture(80, 25)
try:
agent.set_size(-80, 70)
Expand Down
39 changes: 20 additions & 19 deletions winpty/tests/test_ptyprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

# yapf: enable


@pytest.fixture(scope='module')
def pty_fixture(cmd=None, env=None):
cmd = cmd or 'cmd'
return PtyProcess.spawn(cmd, env=env)
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():
def test_read(pty_fixture):
pty = pty_fixture()
loc = os.getcwd()
data = ''
Expand All @@ -33,7 +34,7 @@ def test_read():
pty.terminate()


def test_write():
def test_write(pty_fixture):
pty = pty_fixture()

text = u'Eggs, ham and spam ünicode'
Expand All @@ -45,7 +46,7 @@ def test_write():
pty.terminate()


def test_isalive():
def test_isalive(pty_fixture):
pty = pty_fixture()
pty.write('exit\r\n')

Expand All @@ -64,7 +65,7 @@ def test_isalive():
pty.terminate()


def test_readline():
def test_readline(pty_fixture):
env = os.environ.copy()
env['foo'] = 'bar'
pty = pty_fixture(env=env)
Expand All @@ -76,69 +77,69 @@ def test_readline():
pty.terminate()


def test_close():
def test_close(pty_fixture):
pty = pty_fixture()
pty.close()
assert not pty.isalive()


def test_flush():
def test_flush(pty_fixture):
pty = pty_fixture()
pty.flush()
pty.terminate()


def test_intr():
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():
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():
def test_send_eof(pty_fixture):
cat = pty_fixture('cat')
cat.sendeof()
assert cat.wait() == 0


def test_isatty():
def test_isatty(pty_fixture):
pty = pty_fixture()
assert pty.isatty()
pty.terminate()
assert not pty.isatty()


def test_wait():
def test_wait(pty_fixture):
pty = pty_fixture(cmd=[sys.executable, '--version'])
assert pty.wait() == 0


def test_exit_status():
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():
def test_kill(pty_fixture):
pty = pty_fixture()
pty.kill(signal.SIGTERM)
assert not pty.isalive()
assert pty.exitstatus == signal.SIGTERM


def test_getwinsize():
def test_getwinsize(pty_fixture):
pty = pty_fixture()
assert pty.getwinsize() == (24, 80)
pty.terminate()


def test_setwinsize():
def test_setwinsize(pty_fixture):
pty = pty_fixture()
pty.setwinsize(50, 110)
assert pty.getwinsize() == (50, 110)
Expand Down
22 changes: 12 additions & 10 deletions winpty/tests/test_winpty_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@


@pytest.fixture(scope='module')
def pty_fixture(cols, rows):
pty = PTY(cols, rows)
pty.spawn(CMD)
return pty
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 = pty_fixture(80, 25)
def test_read(pty_fixture):
pty = pty_fixture()
loc = os.getcwd()
line = ''
while loc not in line:
Expand All @@ -39,8 +41,8 @@ def test_read():
del pty


def test_write():
pty = pty_fixture(80, 25)
def test_write(pty_fixture):
pty = pty_fixture()
line = pty.read()
while len(line) < 10:
line = pty.read()
Expand All @@ -58,8 +60,8 @@ def test_write():
del pty


def test_isalive():
pty = pty_fixture(80, 25)
def test_isalive(pty_fixture):
pty = pty_fixture()
pty.write(u'exit\r\n')

text = u'exit'
Expand Down

0 comments on commit c7e1f1e

Please sign in to comment.