Commit 5bae8066 authored by Ondřej Nový's avatar Ondřej Nový

New upstream version 1.7.0

parent 3469d0cc
1.7.0 (2018-10-11)
==================
- fix #174: use ``shutil.get_terminal_size()`` in Python 3.3+ to determine the size of the
terminal, which produces more accurate results than the previous method.
- fix pytest-dev/pytest#2042: introduce new ``PY_IGNORE_IMPORTMISMATCH`` environment variable
that suppresses ``ImportMismatchError`` exceptions when set to ``1``.
1.6.0 (2018-08-27)
==================
......
Metadata-Version: 1.2
Name: py
Version: 1.6.0
Version: 1.7.0
Summary: library with cross-python path, ini-parsing, io, code, log facilities
Home-page: http://py.readthedocs.io/
Author: holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others
......
Metadata-Version: 1.2
Name: py
Version: 1.6.0
Version: 1.7.0
Summary: library with cross-python path, ini-parsing, io, code, log facilities
Home-page: http://py.readthedocs.io/
Author: holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others
......
......@@ -8,6 +8,7 @@ Helper functions for writing to terminals and files.
import sys, os, unicodedata
import py
py3k = sys.version_info[0] >= 3
py33 = sys.version_info >= (3, 3)
from py.builtin import text, bytes
win32_and_ctypes = False
......@@ -24,10 +25,15 @@ if sys.platform == "win32":
def _getdimensions():
import termios,fcntl,struct
call = fcntl.ioctl(1,termios.TIOCGWINSZ,"\000"*8)
height,width = struct.unpack( "hhhh", call ) [:2]
return height, width
if py33:
import shutil
size = shutil.get_terminal_size()
return size.lines, size.columns
else:
import termios, fcntl, struct
call = fcntl.ioctl(1, termios.TIOCGWINSZ, "\000" * 8)
height, width = struct.unpack("hhhh", call)[:2]
return height, width
def get_terminal_width():
......
......@@ -683,7 +683,9 @@ class LocalPath(FSBase):
except py.error.ENOENT:
issame = False
if not issame:
raise self.ImportMismatchError(modname, modfile, self)
ignore = os.getenv('PY_IGNORE_IMPORTMISMATCH')
if ignore != '1':
raise self.ImportMismatchError(modname, modfile, self)
return mod
else:
try:
......
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '1.6.0'
version = '1.7.0'
from collections import namedtuple
import py
import os, sys
......@@ -10,16 +11,22 @@ def test_get_terminal_width():
assert x == terminalwriter.get_terminal_width
def test_getdimensions(monkeypatch):
fcntl = py.test.importorskip("fcntl")
import struct
l = []
monkeypatch.setattr(fcntl, 'ioctl', lambda *args: l.append(args))
try:
terminalwriter._getdimensions()
except (TypeError, struct.error):
pass
assert len(l) == 1
assert l[0][0] == 1
if sys.version_info >= (3, 3):
import shutil
Size = namedtuple('Size', 'lines columns')
monkeypatch.setattr(shutil, 'get_terminal_size', lambda: Size(60, 100))
assert terminalwriter._getdimensions() == (60, 100)
else:
fcntl = py.test.importorskip("fcntl")
import struct
l = []
monkeypatch.setattr(fcntl, 'ioctl', lambda *args: l.append(args))
try:
terminalwriter._getdimensions()
except (TypeError, struct.error):
pass
assert len(l) == 1
assert l[0][0] == 1
def test_terminal_width_COLUMNS(monkeypatch):
""" Dummy test for get_terminal_width
......
......@@ -475,13 +475,22 @@ class TestImport:
assert obj.x == 42
assert obj.__name__ == 'execfile'
def test_pyimport_renamed_dir_creates_mismatch(self, tmpdir):
def test_pyimport_renamed_dir_creates_mismatch(self, tmpdir, monkeypatch):
p = tmpdir.ensure("a", "test_x123.py")
p.pyimport()
tmpdir.join("a").move(tmpdir.join("b"))
with pytest.raises(tmpdir.ImportMismatchError):
tmpdir.join("b", "test_x123.py").pyimport()
# Errors can be ignored.
monkeypatch.setenv('PY_IGNORE_IMPORTMISMATCH', '1')
tmpdir.join("b", "test_x123.py").pyimport()
# PY_IGNORE_IMPORTMISMATCH=0 does not ignore error.
monkeypatch.setenv('PY_IGNORE_IMPORTMISMATCH', '0')
with pytest.raises(tmpdir.ImportMismatchError):
tmpdir.join("b", "test_x123.py").pyimport()
def test_pyimport_messy_name(self, tmpdir):
# http://bitbucket.org/hpk42/py-trunk/issue/129
path = tmpdir.ensure('foo__init__.py')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment