Skip to content

Commit

Permalink
Update tests for pypy
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Feb 13, 2019
1 parent bc86c2f commit fa3fc0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tests/test_interact.py
Original file line number Diff line number Diff line change
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
4 changes: 3 additions & 1 deletion tests/test_stream.py
Original file line number Diff line number Diff line change
@@ -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 fa3fc0f

Please sign in to comment.