Skip to content

Commit

Permalink
Merge 4dababd into be126d6
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Feb 13, 2019
2 parents be126d6 + 4dababd commit 38f8636
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 17 deletions.
19 changes: 19 additions & 0 deletions .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
8 changes: 8 additions & 0 deletions .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
36 changes: 26 additions & 10 deletions .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
Expand Down
4 changes: 3 additions & 1 deletion aioconsole/rlwrap.py
Expand Up @@ -2,14 +2,16 @@

import sys
import ctypes
import fcntl
import signal
import builtins
import subprocess
from concurrent.futures import ThreadPoolExecutor

from . import compat

if compat.platform == 'darwin':
import fcntl


def rlwrap_process(args, prompt_control, use_stderr=False):
assert len(prompt_control) == 1
Expand Down
7 changes: 6 additions & 1 deletion tests/test_apython.py
Expand Up @@ -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([
Expand Down
7 changes: 4 additions & 3 deletions tests/test_interact.py
Expand Up @@ -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'])
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_server.py
Expand Up @@ -9,7 +9,8 @@
@pytest.mark.asyncio
@asyncio.coroutine
def test_server(event_loop):
server = yield from start_console_server(port=0, banner='test')
server = yield from start_console_server(
host="127.0.0.1", port=0, banner='test')
address = server.sockets[0].getsockname()
reader, writer = yield from asyncio.open_connection(*address)
assert (yield from reader.readline()) == b'test\n'
Expand Down
4 changes: 3 additions & 1 deletion tests/test_stream.py
@@ -1,5 +1,6 @@
import os
import io
import gc
import sys
import pytest
import asyncio
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 38f8636

Please sign in to comment.