From f6f490085787f1bdf73f47ac357159e6f657169d Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Wed, 13 Feb 2019 13:34:12 +0100 Subject: [PATCH 1/4] Fix windows compatibility --- aioconsole/rlwrap.py | 4 +++- tests/test_apython.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/aioconsole/rlwrap.py b/aioconsole/rlwrap.py index d7bc655..5e59666 100644 --- a/aioconsole/rlwrap.py +++ b/aioconsole/rlwrap.py @@ -2,7 +2,6 @@ import sys import ctypes -import fcntl import signal import builtins import subprocess @@ -10,6 +9,9 @@ from . import compat +if compat.platform == 'darwin': + import fcntl + def rlwrap_process(args, prompt_control, use_stderr=False): assert len(prompt_control) == 1 diff --git a/tests/test_apython.py b/tests/test_apython.py index 7f1bdf5..a8e2633 100644 --- a/tests/test_apython.py +++ b/tests/test_apython.py @@ -49,7 +49,12 @@ def readline(fin, ferr, prompt): api = m_ctypes.pythonapi call_readline = api.PyOS_Readline call_readline.side_effect = readline - yield call_readline + + if platform == 'darwin': + with patch('aioconsole.rlwrap.fcntl', create=True): + yield call_readline + else: + yield call_readline if call_readline.called: m_ctypes.c_void_p.in_dll.assert_has_calls([ From 4e77b34de0c4cfa193803d07e2647d96f48449b4 Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Wed, 13 Feb 2019 15:01:39 +0100 Subject: [PATCH 2/4] Update tests for pypy --- tests/test_interact.py | 7 ++++--- tests/test_stream.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_interact.py b/tests/test_interact.py index 3e4f64a..c155d1b 100644 --- a/tests/test_interact.py +++ b/tests/test_interact.py @@ -34,9 +34,10 @@ def stdcontrol(event_loop, monkeypatch): @asyncio.coroutine -def assert_stream(stream, expected): +def assert_stream(stream, expected, loose=False): + s = None if loose else "\n" for line in expected.splitlines(): - assert line == (yield from stream.readline()).decode().strip('\n') + assert line.strip(s) == (yield from stream.readline()).decode().strip(s) @pytest.fixture(params=['unix', 'not-unix']) @@ -90,7 +91,7 @@ def test_interact_syntax_error(event_loop, monkeypatch): # Skip line yield from reader.readline() yield from assert_stream(reader, ' a b') - yield from assert_stream(reader, ' ^') + yield from assert_stream(reader, ' ^', loose=True) yield from assert_stream(reader, 'SyntaxError: invalid syntax') yield from assert_stream(reader, sys.ps1) diff --git a/tests/test_stream.py b/tests/test_stream.py index ac5d0da..7504f41 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -1,5 +1,6 @@ import os import io +import gc import sys import pytest import asyncio @@ -43,8 +44,9 @@ def test_create_standard_stream_with_pipe(): get_extra_info = Mock(side_effect=OSError) writer2._transport.get_extra_info = get_extra_info del reader, writer1, writer2 - stdout.fileno.assert_called_once_with() + gc.collect() # Force garbage collection - necessary for pypy get_extra_info.assert_called_once_with('pipe') + stdout.fileno.assert_called_once_with() @pytest.mark.asyncio From ec8327c13dcdf55343d76067465e58bde32c23a4 Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Wed, 13 Feb 2019 17:54:15 +0100 Subject: [PATCH 3/4] Add appveyor config Altough appveyor is not usable at the moment --- .appveyor.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..de81343 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,19 @@ +environment: + matrix: + - PYTHON: "C:\\Python34-x64" + - PYTHON: "C:\\Python35-x64" + - PYTHON: "C:\\Python36-x64" + - PYTHON: "C:\\Python37-x64" + +build: off + +install: + - SET PATH=%PYTHON%;%PYTHON%\Scripts;;%PATH% + - python --version + - pip install -U coveralls pytest + +test_script: + - python setup.py test + +after_test: + - coveralls From b5ddff257f3449ddb62803386f4dc9ef8dbba90f Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Wed, 13 Feb 2019 17:54:06 +0100 Subject: [PATCH 4/4] Update travis matrix --- .travis-osx-install | 8 ++++++++ .travis.yml | 36 ++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100755 .travis-osx-install diff --git a/.travis-osx-install b/.travis-osx-install new file mode 100755 index 0000000..6c74329 --- /dev/null +++ b/.travis-osx-install @@ -0,0 +1,8 @@ +#!/bin/sh +curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.6.pkg +sudo installer -pkg macpython.pkg -target / +ls /Library/Frameworks/Python.framework/Versions/*/bin/ +PYTHON_EXE=/Library/Frameworks/Python.framework/Versions/*/bin/python3 +sudo $PYTHON_EXE -m pip install virtualenv +$PYTHON_EXE -m virtualenv testenv +source testenv/bin/activate diff --git a/.travis.yml b/.travis.yml index a5676c5..066fba8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,32 @@ +os: linux +dist: xenial language: python +python: +- 3.5 +- pypy3.5 +- 3.6 +- 3.7 +- 3.8-dev + matrix: - include: - - python: 3.4 - - python: 3.5 - - python: 3.6 - - python: 3.7 - dist: xenial - sudo: true - - python: 3.8-dev - dist: xenial - sudo: true + include: + # Linux - 3.4 + - os: linux + dist: trusty + language: python + python: 3.4 + # OSX - 3.6 + - os: osx + language: generic + env: MACPYTHON=3.6.8 + before_install: source .travis-osx-install + # OSX - 3.7 + - os: osx + language: generic + env: MACPYTHON=3.7.2 + before_install: source .travis-osx-install + install: pip install -U coveralls pytest script: python setup.py test